Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster
import wx
import wx.calendar

class MyFrame(wx.Frame):	
	def __init__(self, parent, title):
		wx.Frame.__init__(self, parent, -1, 'tLapse', wx.DefaultPosition, (560, 472), style=wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.RESIZE_BORDER | wx.FRAME_NO_TASKBAR | 0 | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
		self.panel = wx.Panel(self, -1)

		self.button1 = wx.Button(self.panel, -1, 'Quit', (448,400), (75, 20))
		self.button1.Bind(wx.EVT_BUTTON, self.exit_now)
		self.button1.SetFont(wx.Font(8.25, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
		self.button1.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))

		self.textbox1 = wx.TextCtrl(self.panel, -1, 'Time in hours', (336,64), size=(100, 20), style=wx.TE_PROCESS_ENTER)
		self.textbox1.SetFocus()
		wx.EVT_TEXT_ENTER(self.textbox1, -1, self.OnEnter)
		 
		self.textbox1.SetBackgroundColour(wx.Colour(255, 255, 255))
		self.textbox1.SetFont(wx.Font(8.25, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
		self.textbox1.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))

		self.label2 = wx.StaticText(self.panel, -1, 'Enter time in hours after which the selected program will open:', (8,64), (316, 17))
		self.label2.SetFont(wx.Font(8.25, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
		self.label2.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))

		self.label3 = wx.StaticText(self.panel, -1, 'Welcome to tLapse. Select the program which you want to open:', (8,16), (332, 23))
		self.label3.SetFont(wx.Font(8.25, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
		self.label3.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))

		self.textbox2 = wx.TextCtrl(self.panel, -1, '', (48,112), size=(279, 146), style=wx.TE_MULTILINE)
		self.textbox2.SetBackgroundColour(wx.Colour(255, 255, 255))
		self.textbox2.SetFont(wx.Font(8.25, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
		self.textbox2.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))

	def OnEnter(self, evt):
                time_user=self.textbox1.GetValue()
		self.textbox1.SetValue("")
                self.textbox2.write(time_user)

	def exit_now(self, event):
		self.Close()
                
class MyApp(wx.App):
	def OnInit(self):
		frame = MyFrame(None, 'App')
		frame.Show(True)
		self.SetTopWindow(frame)
		return True

app = MyApp(True)
app.MainLoop()
Stefano Mtangoo 455 Senior Poster

I have never done RAD GUI designing.
I tried recently wxGlade and In minutes I was able to do alot. It is ugly but really powerful. It generates clean pyCode and I recommend it. Take simple tutorial it come with and there you have your flight. I think it should have been designed like wxformbuilder but I thank them even for "ugly" wxglade

scru commented: props to you for being able to stand the ugliness. +6
Stefano Mtangoo 455 Senior Poster

Starting:
PyGTK:

  1. Wingware's Wing IDE - www.wingware.com

wxPython:

  1. Chandra Client (don't remember its full name)
Stefano Mtangoo 455 Senior Poster

To help people who come from console application and who wants to implement GUI, it is better for them to know the real world application made by available toolkit. I suggest this be the place to show real world apps doen by toolkits in Python Language
Hope it will help Newcomers to decide GUI toolkit for them

Stefano Mtangoo 455 Senior Poster

Wow! It worked. It seem that the result was not string.
Thanks everyone who contributed to that invaluable help!
Cheers :)

Stefano Mtangoo 455 Senior Poster

Just in case you don't fine wxGlade or BoaConstructor to be quite what you need (or if you just can't get past how ugly they are), you can try QtDesigner for pyQT (comes with the pyQT package).

Be sure first you like their GPL/Commercial licence. I lately visited PyQT web and sad enough, they still stick to their Old bad (at least to me) Licence. I would like to see them switching to LGPL as the QT 4.5.x That would be great!

Stefano Mtangoo 455 Senior Poster

I'll give a try on that!
Thanks

Stefano Mtangoo 455 Senior Poster

Good start is wxPython's web www.wxpython.org
Then Go to their wiki. If you will walk there there is a link to Jan Bodnar's site www.zetcode.com/wxpython and www.learningpython.org Also there is a mouse vs python (google it) Are great sites for tutorial.

Hard coding is better than GUI Builder, for your code will be cleaner and better documentation :)

Stefano Mtangoo 455 Senior Poster

and consider wxPython as to my HO is the best toolkit. I'm waiting for PyQT to switch to LGPL Like its father QT. Until then I recommend wxPython.
www.wxpython.org

For simple stuffs, Old good TkInter might help! :)

Stefano Mtangoo 455 Senior Poster

I don't have ever played with Macintosh, so I won't say about IDLE but just alternatives.
1. Download Wingware's Wing IDE www.wingware.com (Version 101 is free and have a lot for learning)
2. Use Ulipad, great editor for python (Google it)
3. Download VIDLE from Vpython Community www.vpython.org
4. DrPython is another IDE of choice (Google it)
5. Old dead BOA Constructor is there also! (Google it)

Just my 2cents ;)

Stefano Mtangoo 455 Senior Poster

Ok I will try and post back.

Stefano Mtangoo 455 Senior Poster

When and how did it got started to misbehave?

Stefano Mtangoo 455 Senior Poster

Burning ISO should not be a problem unless you cannot get a neighbor with a CD/DVD burner. In that case you can use internet cafe to do so and it should be heap enough to afford. Is that right

Stefano Mtangoo 455 Senior Poster

So any suggestion? I want to repair it or if I can, recover the data

Stefano Mtangoo 455 Senior Poster

I cannot access my Toshiba External HDD. When I use chkdsk, It complains "Unable to determine volume version and state, chkdsk aborted". I cannot think of any other way to restore it. I don't have access to buy recovery software so, freeware is preferrable.
Thanks all

Stefano Mtangoo 455 Senior Poster

I dont know. May be wxpython lists may be best place for the question. Don't forget to be back when you have an answer:
http://www.wxpython.org/maillist.php

Stefano Mtangoo 455 Senior Poster

Consider the shadwickman's saying.
But easy answer is use of break to terminate the loop. any loop can be exite anytime using break statement

Stefano Mtangoo 455 Senior Poster

Have you checked wxpython demo?
if no Download it and play around with it
http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-docs-demos-2.8.10.1.exe

Not sure if it is possible

Stefano Mtangoo 455 Senior Poster

Any help

Stefano Mtangoo 455 Senior Poster

So, what I got wrong?
Items is a list of tuples and so data becomes a tuple and hence data[0] an integer (Index of a tuple). Is there anything wrong with that. How can I rectify that?

Stefano Mtangoo 455 Senior Poster

Big up Ene!
Good work! I didn't knew that Python is that much intelligent
+1 :)

Stefano Mtangoo 455 Senior Poster

Embedding image? Yes possible but sound? Not sure!

Stefano Mtangoo 455 Senior Poster

Here is a function that populates the control

def OnPopulate(self, items):
        print items
        for data in items:
            print data
            index = self.screen.InsertStringItem(sys.maxint, data[0])
            self.screen.SetStringItem(index, 0, str(data[0]))
            self.screen.SetStringItem(index, 1, str(data[1]))
            self.screen.SetStringItem(index, 2, str(data[2]))
            self.screen.SetStringItem(index, 3, str(data[3]))
Stefano Mtangoo 455 Senior Poster

Hi,
I'm working on little phone book program with wxPython and SQLite. I can get database populated and can retrieve back the phones and names, but when I do fill them in ListCtrl it throws cruel errors :)
Here is the retrieved data from database:
[(1, u'Steve', u'Giddy', u'0654743553'), (2, u'Majia', u'Ukonovic', u'65473032'), (3, u'Joseph', u'Ryanc', u'7663991109')]

When I replace this with another list of tuples, everything loads fine, so I guess something is wrong with this result !
and here is the error it throws:
TypeError: String or Unicode type required
File "F:\My Projects\Python\PhoneBook.py\mainfile.pyw", line 117, in <module>
app.MainLoop()
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7967, in MainLoop
wx.PyApp.MainLoop(self)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7292, in MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
File "F:\My Projects\Python\PhoneBook.py\mainfile.pyw", line 104, in OnAdd
self.OnPopulate(items)
File "F:\My Projects\Python\PhoneBook.py\mainfile.pyw", line 79, in OnPopulate
index = self.screen.InsertStringItem(sys.maxint, data[0])
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 4761, in InsertStringItem
return _controls_.ListCtrl_InsertStringItem(*args, **kwargs)

Stefano Mtangoo 455 Senior Poster

I've never used 2.4 and I enjoy mysql-python wherever I need it. There is version for Python 2.5

Stefano Mtangoo 455 Senior Poster

Ok, may be :)
I don't see the reason of not using Python 2.X I still use 2.5 and works fine. I think this version have got so many modules available and so, it is for production level!

Stefano Mtangoo 455 Senior Poster

Thanks J,
I will do that and post back results! :)

Stefano Mtangoo 455 Senior Poster

I didn't :)

Stefano Mtangoo 455 Senior Poster

Anyone familiar with sockets? :)

Stefano Mtangoo 455 Senior Poster

What error does it spawn?

Stefano Mtangoo 455 Senior Poster

Also just an advice,
why not use codeblocks instead of hard compiling hand to hand?
It is here:
www.codeblocks.org
Just MHO

Stefano Mtangoo 455 Senior Poster

PyQT is out for QT fans.
It is in pyQT 4.5
For more, see here:
http://www.riverbankcomputing.co.uk/news/pyqt-45

Stefano Mtangoo 455 Senior Poster

Either step down to python 2.x and enjoy python-mysql or change option to use SQLite. SQLite comes with Python, so I guess it is in version 3 also.

Stefano Mtangoo 455 Senior Poster

Hi,
I have never been into sockets, so I decided to dive in.
With some help from devshed, I managed to make a server as shown below. But I cant get it receive data from client.
Please correct me :)

ERROR:
socket.error: (10057, 'Socket is not connected')

import socket as skt

class MServer:
    def __init__(self):
        print "Welcome to Hosanna Chat server: \n Server started...."
    
    # Make a socket
    def makesock(self, stype = skt.AF_INET, smode = skt.SOCK_STREAM):
        newsock = skt.socket(stype, smode) 
        return newsock
    # Bind socket to address
    def bindsock(self, sock, name="localhost", address_port=80):
        sock.bind((name, address_port))
        
    #Listen to connections
    def listensock(self, max_conn, sock):
        sock.listen(max_conn)
        print "Listening...."
    
    #Aceept the connection
    def acceptsock(self, sock):
        clientsock, address = sock.accept()
        print "Accepted connection from  Client socket Address %s, port %s" %address
    
    #Get data from client
    def getdata(self, buff, sock):
        data = sock.recv(buff)
        return data
        
        
sv1 = MServer()
s1 = sv1.makesock()
sv1.bindsock(s1)
sv1.listensock(2, s1)
while True:
    sv1.acceptsock(s1)
    data = sv1.getdata(1024, s1)
    print data
Stefano Mtangoo 455 Senior Poster

Is it still impossible to do?

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

I mean this line of code:

for i in packages:
            index = self.list.InsertStringItem(sys.maxint, i[0])
            self.list.SetStringItem(index, 1, i[1])
            self.list.SetStringItem(index, 2, i[2])
Stefano Mtangoo 455 Senior Poster

You see nothing because your function doesn't do anything that is visible. Try to use print statement to show something (Like J's example) or return something from your method

try this:
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html

Stefano Mtangoo 455 Senior Poster

I was out of programming for long and now I'm just trying back to regain my knowledge on the language. I have forgotten how the ListCtrl get populated. Here is the tutorial but I cant explain the mechanism. Please help me to understand the whole process.
Cheers :)


http://zetcode.com/wxpython/advanced/

Stefano Mtangoo 455 Senior Poster

Thanks sir :)

Stefano Mtangoo 455 Senior Poster

If DevC++ hates you why not try Code::Blocks?
www.codeblocks.org

Stefano Mtangoo 455 Senior Poster

Alternatively you can add python to your environment variables so that you just navigate to the file in command prompt and type command: python yourscript.py and there you go!

Stefano Mtangoo 455 Senior Poster

I'm learning wxWidgets and would like to know which event, connect or using static event tables? Why will you choose one from the other

Which of the two types of event system you guys suggest? Is it using EVENT TABLE or CONNECT?

Thanks alot

Stefano Mtangoo 455 Senior Poster

I'm learning wxWidgets and would like to know which event, connect or using static event tables? Why will you choose one from the other

Stefano Mtangoo 455 Senior Poster

Enter safe mode, just reboot PC and when it restarts just press F8 until choices are given:
1. Safe mode
2. safe mode with networking
3.........

Stefano Mtangoo 455 Senior Poster

This tutorial helped me alot to start wxPython
http://zetcode.com/wxpython

Stefano Mtangoo 455 Senior Poster

Doubt it would be age (being around 6/7 months old) and power spike is out because the wall switch was turned off, and it runs through a surge strip as well. Anywhere (In UK) can i get the HDD repaired for as low a cost as possible?

1. Try remove HDD and boot the system. Then Power off your PC. Put your HDD back and try power on!

2. Remove CMOS battery so as it can forget everything and then try reboot it and setup everything in CMOS and see what it does!

Stefano Mtangoo 455 Senior Poster

ok, let me clarify with example. I have code like belo and want to split it inot .h and .cpp, what are rules to follow?
Thanks

#include <wx/wx.h>
class MyApp : public wxApp
{
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
    public:
        MyFrame(const wxString& title);
};


MyFrame::MyFrame(const wxString& title)
        : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
  Centre();
}

bool MyApp::OnInit()
{

    MyFrame *newFrame = new MyFrame(wxT("Hello Mary!"));
    //wxPanel *myPanel = new wxPanel(this, wxID_ANY); ====== to be attended
    newFrame->Show(true);
    return true;
}

IMPLEMENT_APP(MyApp);
Stefano Mtangoo 455 Senior Poster

Thanks siddhant3