Re: [Tutor] tkinter question

2012-04-27 Thread Alan Gauld

On 27/04/12 05:08, Khalid Al-Ghamdi wrote:


I've created this simple window with two widgets (a label and a button)
the button is supposed to  exit the root window, but the problem is it
doesn't seem to,
top=tkinter.Tk()

 ...

tkinter.mainloop()


try

  top.mainloop()

I'm not sure if that makes a difference but it is usual to call 
mainloop() on the root widget, calling at the module level may do 
something strange...


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] TKinter question

2006-03-21 Thread Alan Gauld
 My code writes to a text file 'table.txt', and 'table.txt' is displayed in
 the GUI. The user can generate new data at the click of a button
 which re-writes 'table.txt', but I can only add the new table to the GUI
 window rather than 'update' the existing one.

class MoC:
def __init__(self, master):
frame = Frame(master, width=600, height=800, bd=1)
frame.pack()

you are not storing the widgets so they will be lost when you leave 
__init__.

use self.frame, self.text etc so you can access them in other methods.

#Text box frame
text=Text(iframe5, height=10, width =70)
fd = open('table.txt')  #table.txt must be in the same folder
lines = fd.read()
fd.close()
text.insert(END, lines)

This putes the lines at the end of the text box.
You want to use '1.0' as the position instead of END.
Check the documentation on the Text widget in the Tkinter
reference manual.

#Command definitions
def quit(self):
root.destroy()

def DisplayUpdate(self): #The command definition used to update the 
display.
#Could I insert a line here to remove the existing frame/text box 
first?
iframe5 = Frame(root, bd=2, relief=SUNKEN)
text = Text(iframe5, height=10, width =70)

This creates a new text widget rather than using the one created in init.
If you use self.text in init you can reference thatv same widget here.

fd = open('table.txt')
lines = fd.read()
fd.close()

Since you do this in two places it might be worth making it a
loadFile() method or similar?

text.insert(END, lines)

If you use '1.0' it should overwrite the old contents. However if
the second is shorter you will get remnants so you might want
to clear the contents too, look at the delete method and use
a start of '1.0' and an end of END...

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] TKinter Question

2005-11-08 Thread Michael Lange
On Tue, 08 Nov 2005 00:10:16 -0600
Rob Dowell [EMAIL PROTECTED] wrote:

 Just a quick TKinter question. Is it possible to have custom 
 frames/widgets? In other words can I customize the way that the GUI 
 looks (i.e. rounded corners on the frames, beveled/raised edges, etc.) I 
 was just wondering if it was possible and if it is possible then where I 
 might get some information on how to do it. Thank you very much, Rob.
 

Hi Rob,

I'm not sure what you mean with beveled/raised edges , maybe setting the 
widget's
relief to GROOVE or RIDGE does what you want?
Rounded corners are much more complicated; you will probably need the shape 
extension for Tk
which adds non-rectangular window support to Tk.
A version of shape that works with unix systems is included in the tkdnd drag 
and drop extension
(http://sourceforge.net/projects/tkdnd); I wrote a Tkinter wrapper for tkdnd 
(http://www.8ung.at/klappnase/TkinterDnD/TkinterDnD.html)
that makes it possible to use tkdnd from python. If you need windows support, 
you can try
a newer version of shape (http://www.cs.man.ac.uk/~fellowsd/tcl/shapeidx.html) 
that seems to support
windows platforms, too.

Regards

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] TKinter Question

2005-11-08 Thread Danny Yoo


 On 08/11/05, Rob Dowell [EMAIL PROTECTED] wrote:
  Just a quick TKinter question. Is it possible to have custom
  frames/widgets? In other words can I customize the way that the GUI
  looks (i.e. rounded corners on the frames, beveled/raised edges, etc.) I
  was just wondering if it was possible and if it is possible then where I
  might get some information on how to do it. Thank you very much, Rob.

 Have you looked at the options for the frame class? Eg, Frame(parent,
 borderwidth=2, relief=RIDGE)


Hi Rob,

Also, some people have written some custom widget classes as part of the
Python Megawidgets project:

http://pmw.sourceforge.net/

But it sounds more like you might be interested in things like skinning;
unfortunately, I don't know too much about that.

Best of wishes to you!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor