pellegrini | 3 Sep 15:26 2008
Picon

Layout problem using grid manager

Hello Everybody,

I have a problem using the grid manager.

I would expect the following code to place:
    -button 1 and 2 at the top of the left frame
    -button 3 at the bottom of the left frame
    -button 4 at the top of the right frame
Instead, it places:
    -button 1, 2, 3 at the center of the left frame
    -button 4 at the center of the right frame.

Would you have any idea how what is wrong and how to solve this using 
the grid manager (and only this one) ?

#####################################################"
import Tkinter as tk

root=tk.Tk()

root = tk.Toplevel()

frame1=tk.Frame(root,bg='black',width=200,height=300)
frame1.grid(row = 0, column = 0)
frame1.grid_propagate(0)

button1 = tk.Button(frame1,text='button 1')
button1.grid(padx=3,pady=3, sticky = N)

button2 = tk.Button(frame1,text='button 2')
(Continue reading)

Reson | 3 Sep 02:16 2008
Picon
Picon

Re: Tkinter, toplevel and images


Hi!
changing extension to pyw (in windows) can help ;)
Reson

ptg wrote:
> 
> 
> Hi 
>  I'm trying to build a small application that can display some images 
>  in a toplevel window. I have this code: 
>  def Results(master): 
>      from Tkinter import Toplevel, Button, Label 
>      from PIL import ImageTk 
>      figures = ['first.png', 'second.png'] 
>      ResultsWindow = Toplevel(master) 
>      ResultsWindow.title('Results') 
>      picts = [ImageTk.PhotoImage(file = x) for x in figures] 
>      butRW = Button(ResultsWindow, text = 'CLOSE', command = 
>  ResultsWindow.destroy) 
>      butRW.pack() 
>      height = sum([x.height() for x in picts]) 
>      width = picts[0].width() 
>      y = 0 
>      for pict in picts: 
>          label =
> Label(ResultsWindow,image=pict).pack() 
>          y += pict.height() 
>  from Tkinter import Tk 
>  root = Tk() 
(Continue reading)

Guilherme Polo | 4 Sep 02:55 2008
Picon

ANN: Ttk wrapper 0.2.5

Hello,

Today the ttk wrapper 0.2.5 has been released and is available at
http://pypi.python.org/pypi/pyttk/0.2.5. The major highlight is that
it finally includes a test suite, and while writing the tests, several
bugs have been found and corrected.

What is this wrapper for ?
--------------------------------

 This wrapper provides classes to allow using the Tk themed widget
set, which has been included in Tk 8.5 but can be used with earlier
versions if you have Tile installed. Ttk is based on a revised and
enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style
engine.

What is Ttk ?
----------------

 The basic idea of ttk is to separate, to the extent possible, the code
implementing a widget's behavior from the code implementing its
appearance.
 Widget class bindings are primarily responsible for maintaining the
widget state and invoking callbacks, all aspects of the widgets
appearance lies at Themes.

More informations
-----------------------

http://gpolo.ath.cx:81/projects/ttk_to_tkinter
(Continue reading)

Amit Finkler | 7 Sep 10:57 2008
Picon

Hide/Show using withdraw()/deiconify()

Hi,

I want to have a button in my root window which either hides or shows a
different (Toplevel) window. I wrote the following code (assume import
Tkinter)

    RunFrame             = Tkinter.Frame(win1, bd = 2, relief = 'groove')

    MODES = [
              ("2D-On",  "1"),
          ("2D-Off", "2"),
        ]

    hs    = Tkinter.StringVar()
    hs.set("1")

    for text, mode in MODES:
        Run2D = Tkinter.Radiobutton(RunFrame, text = text, variable =
    hs, value = mode, command = Hide_Show_2D(hs))
        Run2D.pack(side = 'left')

where

    def Hide_Show_2D(value):
        """ Hide or show the 2D scan windows (win4) using withdraw() and
    deiconify() """

        if value == '2':
            win4.withdraw()
        else:
(Continue reading)

Fredrik Lundh | 7 Sep 12:29 2008

Re: Hide/Show using withdraw()/deiconify()

Amit Finkler wrote:

>     RunFrame             = Tkinter.Frame(win1, bd = 2, relief = 'groove')

your use of excessive whitespace doesn't exactly make it easier to read 
your code...  I suggest reading PEP 8.

>         Run2D = Tkinter.Radiobutton(RunFrame, text = text, variable =
>     hs, value = mode, command = Hide_Show_2D(hs))
>         Run2D.pack(side = 'left')

when you write

     command=Hide_Show_2D(hs)

Python will *call* the function, take the return value from the 
function, and pass *that* to the Radiobutton.  try inserting a
lambda:

     command=lambda: Hide_Show_2D(hs)

("lambda: expression" creates an anonymous function that evaluates the 
expression when called).

>     def Hide_Show_2D(value):
>         if value == '2':
>             win4.withdraw()
>         else:
>             win4.deiconify()

(Continue reading)

Guilherme Polo | 7 Sep 14:58 2008
Picon

ANN: Ttk wrapper 0.2.6

Hi,

Another pyttk release today, it is at 0.2.6 now, and it is available at
http://pypi.python.org/pypi/pyttk/0.2.6.
This release fixes issue 4
(http://code.google.com/p/python-ttk/issues/detail?id=4&can=1):
"Combobox values fails"
And it also includes documentation, before you would need to visit my
site to read it.

What is this wrapper for ?
--------------------------------

 This wrapper provides classes to allow using the Tk themed widget
set, which has been included in Tk 8.5 but can be used with earlier
versions if you have Tile installed. Ttk is based on a revised and
enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style
engine.

What is Ttk ?
----------------

 The basic idea of ttk is to separate, to the extent possible, the code
implementing a widget's behavior from the code implementing its
appearance.
 Widget class bindings are primarily responsible for maintaining the
widget state and invoking callbacks, all aspects of the widgets
appearance lies at Themes.

More informations
(Continue reading)

Amit Finkler | 7 Sep 10:56 2008
Picon
Picon

Hide / Show using withdraw() / deiconify()

Hi,

I want to have a button in my root window which either hides or shows a
different (Toplevel) window. I wrote the following code (assume import
Tkinter)

    RunFrame             = Tkinter.Frame(win1, bd = 2, relief = 'groove')

    MODES = [
              ("2D-On",  "1"),
          ("2D-Off", "2"),
        ]

    hs    = Tkinter.StringVar()
    hs.set("1")

    for text, mode in MODES:
        Run2D = Tkinter.Radiobutton(RunFrame, text = text, variable =
    hs, value = mode, command = Hide_Show_2D(hs))
        Run2D.pack(side = 'left')

where

    def Hide_Show_2D(value):
        """ Hide or show the 2D scan windows (win4) using withdraw() and
    deiconify() """

        if value == '2':
            win4.withdraw()
        else:
(Continue reading)

Amit Finkler | 8 Sep 20:08 2008
Picon

Hide/Show using withdraw()/deiconify()

Thanks for your help, Fredrik - it worked. I'm also reading PEP 8 and
implementing it in my code.

Amit.
Philippe Garteiser, PhD | 17 Sep 00:19 2008

problem to update gnuplot display using a Scale widget

Hello!
I am using a Tkinter GUI to operate a C binary whose input is a float number gotten from a Scale widget, and whose output is a datafile. I would like to get gnuplot to replot the datafile each time it is overwritten (in essence have the plot refreshed by the Scale slider).
To do that, I pass the function "printer(self,newval)", to the Scale's command. In the printer function, I use os.system to execute the binary, and I operate gnuplot as a special file opened by os.popen, to which I write with the chevrons print statement.

 import os,Tkinter,string,time
 class MyApp:
     def __init__(self, parent):
         self.f=os.popen("gnuplot -","w")
         print >>self.f,"plot \"data.dat\" with lines"
         print >>self.f,"reread"
         self.myParent=parent
 self.myContainer1=Frame(parent)
 self.myContainer1.pack()
 self.v=DoubleVar()
         self.slider1=Scale(self.myParent,from_=0,to=1,resolution=0.001,command=self.printer)#variable=self.v,command=self.printer)
         self.slider1.pack()

     def printer(self,newval):
         os.system("/bin/generate_data_file "+str(newval))
         time.sleep(0.09)
 print >>self.f,"replot\n"
         return newval
 root=Tk()
 myapp=MyApp(root)
 root.mainloop()

 Unfortunately I don't obtain the expected result. The Tk window is there with functioning slider, the generate_data_file is executed and given the proper input value from the slider, but gnuplot is still a problem. The gnuplot window only comes up when I close the Tkinter window, and shuts down rapidly.
Do you have any ideas as to what I need to fix ? Also, it would be great not to have to use the pyGnuplot.py package, as the program will have to run on minimally installed boxes (i.e. standard python, no extra modules allowed).

Thanks a lot !

"It does not pay to leave a live
dragon out of your calculations"
 - Tolkien

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
andrewerol | 18 Sep 17:08 2008
Picon

need to unify several windows in one


----- Original Message ----- 
From: "Andrey Antonov (UCTM)" <andrio <at> uctm.edu>
To: <tkinter-discuss <at> python.org>
Sent: Wednesday, September 10, 2008 3:38 PM
Subject: help: need to unify several windows in one

Hi All,

 I have an application that has 3 windows:
first window is coming from Vpython (http://vpython.org/)
    /for example Tk-Visual.py after the installation of vpython/

second window is a console window
third window from Tkinter - full with widgets.

 I would like to compile my application (for example with py2exe) such that:
 to avoid the black console window and second to redirect it's ALL output 
to
 the text widget.
Because the interface of my application is a bit clumsy, I would like to
 unify all these 3 windows in one.
I am ready to send my application if necessary for further help.

Any links, examples etc. are welcome.
Thx
 Andrew 

Gmane