HELP: Python & Tkinter ?
Hi all, Have just installed Fedora 3 and wish also want to give programming with Python a go. I wish to develop GUI interfaces and believe that 'Tkinter' is the way to go. After installing Python frpm the distro CD I can't use the 'from Tkinter import *' command. When I try, I get the error message below: ImportError: No module named Tkinter So from that I assume I need to install Tkinter ? Should I also find this on the CD ? Is it known as another name as looking on the CD I don't seem to find anything relating to Tkinter. Thanks in advance. Pete -- http://mail.python.org/mailman/listinfo/python-list
Re: Python & Tkinter ?
Fredrik Lundh wrote: > "PGMoscatt" wrote: > >> Have just installed Fedora 3 and wish also want to give programming with >> Python a go. I wish to develop GUI interfaces and believe that 'Tkinter' >> is the way to go. >> >> After installing Python frpm the distro CD I can't use the 'from Tkinter >> import *' command. When I try, I get the error message below: >> >> ImportError: No module named Tkinter >> >> So from that I assume I need to install Tkinter ? >> Should I also find this on the CD ? Is it known as another name as >> looking on the CD I don't seem to find anything relating to Tkinter. > > according to > > http://tkinter.unpythonic.net/wiki/How_20to_20install_20Tkinter > > this should do the trick: > > yum install tkinter > > Thanks Fredrik, yep, that did the trick. Never seen this YUM thing but it's pretty trick. Pete -- http://mail.python.org/mailman/listinfo/python-list
Globals between modules ?
Does Python allow a 'global' variable that can be used between different modules used within an app ? Pete -- http://mail.python.org/mailman/listinfo/python-list
Re: Globals between modules ?
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > PGMoscatt <[EMAIL PROTECTED]> wrote: > >> Does Python allow a 'global' variable that can be used between different >> modules used within an app ? >> >> Pete > > You could explicitly import __main__ and use that as a global namespace > (see example below). Or (perhaps a better idea), you could have a module > dedicated to global storage, and import that in all your other modules > instead of importing __main__. > > - > Roy-Smiths-Computer:play$ cat global.py > #!/usr/bin/env python > > import a > import b > > a.set() > print "x = %s" % x > print "b.get() = %s" % b.get() > - > Roy-Smiths-Computer:play$ cat a.py > import __main__ > > def set(): > __main__.x = "hello" > - > Roy-Smiths-Computer:play$ cat b.py > import __main__ > > def get(): > return __main__.x > - > Roy-Smiths-Computer:play$ ./global.py > x = hello > b.get() = hello Thanks Roy yep, that makes sense. Thanks again. Pete -- http://mail.python.org/mailman/listinfo/python-list
Widget geometry ?
Hi All, I am trying to create a dialog which will have a number of components but having trouble with the placement of various widgets. For example, in my code below you will see I am trying to insert alabel but I want the label to be in the top-left of the dialog but it dosen't want to go there. What am I doing wrong ? Pete from Tkinter import * class show_settings_dialog: def __init__(self,parent): top = self.top = Toplevel(parent) top.title("General Settings...") top["height"]=300 top["width"]=300 top.pack_propagate(0) l1 = Label(top,text="User Name:").grid(row=0, sticky=W) b = Button(top,text="Ok",command=self.ok) b.pack(pady=40) def ok(self): self.top.destroy() -- http://mail.python.org/mailman/listinfo/python-list
Re: Widget geometry ?
Thanks Pierre all working now. Pete Pierre Quentel wrote: > PGMoscatt a Ãcrit : >> Hi All, >> >> I am trying to create a dialog which will have a number of components but >> having trouble with the placement of various widgets. >> >> For example, in my code below you will see I am trying to insert alabel >> but I want the label to be in the top-left of the dialog but it dosen't >> want to go there. >> >> What am I doing wrong ? >> >> Pete >> >> >> >> from Tkinter import * >> >> class show_settings_dialog: >> def __init__(self,parent): >> top = self.top = Toplevel(parent) >> top.title("General Settings...") >> top["height"]=300 >> top["width"]=300 >> top.pack_propagate(0) >> >> l1 = Label(top,text="User Name:").grid(row=0, sticky=W) >> >> b = Button(top,text="Ok",command=self.ok) >> b.pack(pady=40) >> >> >> >> def ok(self): >> self.top.destroy() >> > > You are mixing pack() and grid() to place widgets in the same container. > Try doing b.grid(row=0,column=1) instead > > Regards > Pierre -- http://mail.python.org/mailman/listinfo/python-list
Bitmaps On Buttons ?
I am slowly progressing with my python app. I have got to the point where I would like to place images onto my buttons. I use Tkinter as my GUI libary. The following is how I understand I place an image onto a button - but I am not having much success with it all. Any ideas ? Pete b=Button(ToolBar,padx=1,pady=1,width=2,height=1,command=callquit,) b.bitmap="@button_cancel.xbm" b.place(x=0,y=0) -- http://mail.python.org/mailman/listinfo/python-list