fbonniwell | 1 Jun 18:48 2007
Picon

Executing Tkinter UI from another class


Hello,

I'm still learning how to call class methods from other classes. I'm trying
to figure out what is the best approach to executing a Tkinter UI from
another class. It tells me that it expects two aurguments but received only
1. I expect it may have something to do with "app = App(root)" from
class1.py. 
I also tried defining another procedure that would execute both but I'm
still confused. 
Thanks for the help!

Frank

For example: 

Class1.py
-----------------------------------------------
import Tkinter

class App(Frame):
    def __init__(self , master):
        Frame.__init__(self, master)

    def makeFrames(self):
         code
    def makeRest(self):
         code
    def gerChars(self):
         code
(Continue reading)

Simon Pickles | 6 Jun 18:18 2007
Picon

Newbie needs help with entrybox

Hello, I am new to python and tkinter, but enjoying it so far.

In trying to make a simple GUI I have stumbled on a problem binding an event 
to a function. I've got a listbox for output and an entrybox for input. How 
do I act on the text in the entry box when return is pressed?

Here's my attempt:

# GUI

from Tkinter import*
import tkMessageBox
from time import ctime, time

class CGUI:
    def __init__(self, master):
        frame = Frame(master, name="server")
        frame.pack()
        self.output = Listbox(frame, width=100, height=30)
        self.output.grid(row=0, column=0)
        self.inputBox = Entry(root, bd=5, width=100)
        self.inputBox.bind( "<KeyPress-Return>", 
self.__ParseInput(self.inputBox.get()) )
        self.inputBox.pack(side=BOTTOM, expand=YES, fill=BOTH)

    def __ParseInput(self, s):
        self.output.insert(END, s)

root = Tk()

(Continue reading)

Teresa Stanton | 6 Jun 18:36 2007
Picon

Re: Newbie needs help with entrybox

I'm quite a noob to this also, but I can say that two things are missing:  A
function that your return event would call telling Python what to do when
the event occurs, and mainloop.  

For instance, here is a sample code that when you click on it, will tell you
where the mouse click event occurred:

# File: bind1.py

from Tkinter import *

root = Tk()

def callback(event):     #this will be called later, the definition of the
event.
    print "clicked at", event.x, event.y

frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", callback)  #callback is the function, previously
defined.
frame.pack()

root.mainloop()

HTH

Teresa

-----Original Message-----
From: tkinter-discuss-bounces <at> python.org
(Continue reading)

Gigs_ | 6 Jun 20:22 2007
Picon

Re: Newbie needs help with entrybox

Simon Pickles wrote:
> Hello, I am new to python and tkinter, but enjoying it so far.
>
> In trying to make a simple GUI I have stumbled on a problem binding an event 
> to a function. I've got a listbox for output and an entrybox for input. How 
> do I act on the text in the entry box when return is pressed?
>
> Here's my attempt:
>
> # GUI
>
> from Tkinter import*
> import tkMessageBox
> from time import ctime, time
>
> class CGUI:
>     def __init__(self, master):
>         frame = Frame(master, name="server")
>         frame.pack()
>         self.output = Listbox(frame, width=100, height=30)
>         self.output.grid(row=0, column=0)
>         self.inputBox = Entry(root, bd=5, width=100)
>         self.inputBox.bind( "<KeyPress-Return>", 
> self.__ParseInput(self.inputBox.get()) )
>         self.inputBox.pack(side=BOTTOM, expand=YES, fill=BOTH)
>
>     def __ParseInput(self, s):
>         self.output.insert(END, s)
>
>
(Continue reading)

John McMonagle | 7 Jun 00:58 2007
Picon

Re: Newbie needs help with entrybox

Gigs_ wrote:
> Simon Pickles wrote:
>> Hello, I am new to python and tkinter, but enjoying it so far.
>>
>> In trying to make a simple GUI I have stumbled on a problem binding an event 
>> to a function. I've got a listbox for output and an entrybox for input. How 
>> do I act on the text in the entry box when return is pressed?
>>
>> Here's my attempt:
>>
>> # GUI
>>
>> from Tkinter import*
>> import tkMessageBox
>> from time import ctime, time
>>
>> class CGUI:
>>     def __init__(self, master):
>>         frame = Frame(master, name="server")
>>         frame.pack()
>>         self.output = Listbox(frame, width=100, height=30)
>>         self.output.grid(row=0, column=0)
>>         self.inputBox = Entry(root, bd=5, width=100)
>>         self.inputBox.bind( "<KeyPress-Return>", 
>> self.__ParseInput(self.inputBox.get()) )
>>         self.inputBox.pack(side=BOTTOM, expand=YES, fill=BOTH)
>>
>>     def __ParseInput(self, s):
>>         self.output.insert(END, s)
>>
(Continue reading)

Fabrizio Pollastri | 8 Jun 11:59 2007
Picon

visualtcl as ui designer for tkinter

Hello,
I am trying to use VisualTcl as an interface designer. The tcl file 
produced by VisualTcl is executed in my application as

root = Tk()
root.tk.evalfile('my_tcl_gui.tcl')

I have found two problems.

First, the toplevel "root" supersede the toplevel options defined in the 
tcl file (typically the window title).

Second, the tcl file evaluation stops for "argc" undefined.

Similar tcl files created with TkproE do not suffer this problems.

Thank for any help.

Regards,
F. Pollastri
January Weiner | 15 Jun 02:43 2007
Picon

Ugly fonts with tkinter

I am sure this has been asked a hundred times, but I could not find an
answer in Google.

I have recently started programming using Tkinter and python.  Before,
I was heavily using Perl-Tk, so I have some experience with that kit.
My system is Ubuntu 7.04.

My problem are the extremly ugly bitmap fonts used by Tkinter. Here is
an example:
http://hell.pl/january/python_fonts_example.png

I remember having a similar problem in perl-tk, and having for that
two solutions:
1) choose a different font (optionAdd method of the main window with
e.g. Arial 10)
2) recompiling perl-tk with an antialias option set, so that one gets
fully anti-aliased fonts.

First, I would like to use option (1), but I don't know enough of
tkinter to find it. Furthermore, I would like to know what is the
status on (2).  Is tkinter using somehow its own tk libraries, or does
it relies on system wide libraries? Do you have any experience with
using antialiased fonts with tkinter?

Cheers,
j.
--

-- 
------------ January Weiner 3  ---------------------+---------------
Division of Bioinformatics, University of Muenster  |  Schloßplatz 4
(+49)(251)8321634                                   |  D48149 Münster
(Continue reading)

Fredrik Lundh | 15 Jun 08:31 2007

Re: Ugly fonts with tkinter

January Weiner wrote:

> 1) choose a different font (optionAdd method of the main window with
> e.g. Arial 10)
> 
> First, I would like to use option (1), but I don't know enough of
> tkinter to find it.

use the option_add() method on the root widget.  e.g.

    root.option_add("*Label*font", "Helvetica 15 bold")

</F>
Brill IanT | 17 Jun 22:41 2007
Picon

single button threading

I am writing an application which fetches and parses a large number of urls for hyperlinks.
 
My problem is that when the prog is in the middle of the 'fetching' stage, the gui becomes almost completely unresponsive.
 
This is not at all what I want. I want the user to be able to interact with the gui while this process is going on. Even if just one button, a 'stop' button, is the only thing working, I would be satisfied with that.
 
Is there a way to perhaps thread a button or two while urllib2 is busy fetching a big list of urls? I ask this with some trepidation because I know how thread unfriendly tkinter is.
 
If there is no solution to this, can anyone tell me if reconstructing the gui with wx would help with this matter? I don't want to do this because I am fami liar with tk and find it far easier to work with, but I really have to find a way of solving this problem.
 
Thank you very much for reading, and I hope someone can help me out.

Yahoo! Answers - Get better answers from someone who knows. Try it now.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Cameron Laird | 17 Jun 22:55 2007
Picon

Re: single button threading

On Sun, Jun 17, 2007 at 09:41:25PM +0100, Brill IanT wrote:
			.
			.
			.
> I am writing an application which fetches and parses a large number of urls for hyperlinks.
>    
>   My problem is that when the prog is in the middle of the 'fetching' stage, the gui becomes almost completely unresponsive.
>    
>   This is not at all what I want. I want the user to be able to interact with the gui while this process is going
on. Even if just one button, a 'stop' button, is the only thing working, I would be satisfied with that. 
>    
>   Is there a way to perhaps thread a button or two while urllib2 is busy fetching a big list of urls? I ask this
with some trepidation because I know how thread unfriendly tkinter is.
>    
>   If there is no solution to this, can anyone tell me if reconstructing the gui with wx would help with this
matter? I don't want to do this because I am familiar with tk and find it far easier to work with, but I really
have to find a way of solving this problem.
>    
>   Thank you very much for reading, and I hope someone can help me out.
			.
			.
			.
There are several ways to achieve the responsiveness you describe
within Tkinter.  I'll be tied up the next couple of days; I hope
an answer that delayed still helps you.

Gmane