刘文彬 | 1 Sep 2010 16:32
Picon

Tkinter in interactive mode locks when run from subprocess

Hi, 

In Windows, I made an interactive window by C#, which creates a remote python 
subprocess  to do the interpreting. Communication is done via standard IO redirection. 
The idea is that the python session is an actual process separate from the GUI, 
which has some advantages, like I can have multiple such shells in my application, 
and I can kill them without worrying that my C# app will crash. 


This all works really, I will also launch C# apps. So I was quite happy, untill I tried 
doing some plotting with Tkinter. The problem is that the process 
becomes unresponsive when I do something(more details below) 

I don't know much about creating subprocess and redirecting standard IO of 
subprocess and how they are different from a normal process. So can anyone 
offer some help as to what the problem might be? 

Thanks in advance, 
Kaster

To get to the details: 
I use a textbox component of C# to receive the command and then run it as 
a normal Python console
- When I start  with command "import Tkinter"
-work well,and then command "r = Tkinter.Tk()"
problem is arose, a small window pops up, and then whichever command I 
run in the textbox is not working.

I think may be something block the input so that the command cannot transfer to
the subprocess of python, but I don't know how to resolve the problem.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Guido Carballo-Guerrero | 2 Sep 2010 05:58

Re: python 3.1 - tkinter 8.4 - no tile? (Kevin Walzer)

Yes Kevin, I know Snow come with Tk/Tcl 8.5, but for some reason if one install Python with the dmg installer from Python/Download installer, for some reason ttk doesn't use Tcl/Tk 8.5, but 8.4 instead.

To make Python use 8.5 one have to compile the source code, with the following lines:

$ ./configure --enable-universalsdk --enable-framework
$ make
$ make frameworkinstall

Maybe I'm missing something, but that's how is for me.

Guido

On Sep 1, 2010, at 4:00 AM, tkinter-discuss-request <at> python.org wrote:

Send Tkinter-discuss mailing list submissions to
tkinter-discuss <at> python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tkinter-discuss
or, via email, send a message with subject or body 'help' to
tkinter-discuss-request <at> python.org

You can reach the person managing the list at
tkinter-discuss-owner <at> python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tkinter-discuss digest..."
Today's Topics:

  1. Re: python 3.1 - tkinter 8.4 - no tile? (Kevin Walzer)

From: Kevin Walzer <kw <at> codebykevin.com>
Date: August 31, 2010 6:25:14 AM GMT-06:00
To: tkinter-discuss <at> python.org
Subject: Re: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile?
Reply-To: kw <at> codebykevin.com


On 8/31/10 12:15 AM, Guido Carballo-Guerrero wrote:


I don't understand as well, why the Mac Os x Installer Disk Image don't
come already with Tk/Tcl 8.5, specially since the Windows installer
already comes with all that ready, but well. I would even suggest that
Python should come with ttk.

Those anybody knows what Python doesn't comes already with ttk? Why the
Mac installer doesn't have Tk/Tcl as part of the installation?

ttk is standard, I believe, in 3.1, and perhaps 2.7? (Someone correct me here.)

The Mac installer doesn't include Tcl/Tk because the Mac already ships Tcl/Tk, both 8.5 and 8.4 on Snow Leopard.

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com



_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Kevin Walzer | 2 Sep 2010 13:49
Favicon

Re: python 3.1 - tkinter 8.4 - no tile? (Kevin Walzer)

On 9/1/10 11:58 PM, Guido Carballo-Guerrero wrote:
> Yes Kevin, I know Snow come with Tk/Tcl 8.5, but for some reason if one
> install Python with the dmg installer from Python/Download installer,
> for some reason ttk doesn't use Tcl/Tk 8.5, but 8.4 instead.

That's true if you use the Python.org installer. The Python installed 
with OSX links to 8.5.

>
> To make Python use 8.5 one have to compile the source code, with the
> following lines:
>
> $ ./configure --enable-universalsdk --enable-framework
> $ make
> $ make frameworkinstall
>
>

Also true. That's basically how I built mine. Building from source isn't 
hard.

--Kevin

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
David Cortesi | 2 Sep 2010 15:34
Picon

Re: python 3.1 - tkinter 8.4 - no tile?


Kevin wrote,
On 9/1/10 11:58 PM, Guido Carballo-Guerrero wrote:
Yes Kevin, I know Snow come with Tk/Tcl 8.5, but for some reason if one
install Python with the dmg installer from Python/Download installer,
for some reason ttk doesn't use Tcl/Tk 8.5, but 8.4 instead.

That's true if you use the Python.org installer. The Python installed with OSX links to 8.5.

The Python distributed with OSX is 2.x. If you want to use Python 3.x and
install it from the python.org dmg, the same problem arises (the issue that began
this thread). Apparently, all versions for OSX must be installed by compiling
from source if Tk is to be used.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Kevin Walzer | 2 Sep 2010 15:41
Favicon

Re: python 3.1 - tkinter 8.4 - no tile?


> The Python distributed with OSX is 2.x. If you want to use Python 3.x and
> install it from the python.org <http://python.org> dmg, the same problem
> arises (the issue that began
> this thread). Apparently, all versions for OSX must be installed by
> compiling
> from source if Tk is to be used.

Also true.

Apple ships Tk 8.4 mainly for backwards compatibility, and the MacPython 
maintainers target this version for Tkinter to link to, also for 
backwards compatibility.

I believe ActiveState's Python distribution supports 8.5 on the Mac, by 
the way.

--Kevin

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Sridhar Ratnakumar | 15 Sep 2010 05:49
Picon
Gravatar

Re: python 3.1 - tkinter 8.4 - no tile?

  On 9/2/2010 6:41 AM, Kevin Walzer wrote:
> I believe ActiveState's Python distribution supports 8.5 on the Mac, 
> by the way. 
Yes, ActivePython 2.6 and 2.7 already does.

A new release of ActivePython 3.1 w/ Tcl/Tk 8.5, Mac 64-bit and PyPM is 
to be expected next week (we have an internal beta build if anyone wants 
to try it out).

-srid
Devred, Emmanuel | 21 Sep 2010 21:22
Picon
Favicon

(no subject)

Hello,
I am a total beginner with python and tkinter and I am having a hard time getting my program working, I think the problem come from passing variables.

I would like to have a menu that would with three main buttons, the first one (LUT) let me chosse between two files, the second button (rrs) opens a browser to choose a file and the third button would run a program (or function) that makes some computation between the two files open with button 1 and button 2,

Here is what I have written

from Tkinter import *
from tkFileDialog   import askopenfilename
import numpy as np


class openfile():
    def __init__(self, yn):
        if yn == 0 : self.lut = np.loadtxt("C:\python26\LUTnpdi_chile",dtype=np.float,skiprows=1)
        if yn == 1 : self.lut = np.loadtxt("C:\python26\LUTnpdi_nwa",dtype=np.float,skiprows=1)
        if yn == 2 : filename = askopenfilename(filetypes=[("allfiles","*"),("pythonfiles","*.py")])
        if yn == 2 : self.lut = np.loadtxt(filename,dtype=np.float,skiprows=1)

Class rrs_file(self,rrs):
    filename = askopenfilename(filetypes=[("allfiles","*"),("pythonfiles","*.py")])
    rrs = np.loadtxt(filename,dtype=np.float,skiprows=1)
   
def make_comp():
    result = self.lut[1,2] * rrs[1,2]
    print result
   
def callback():
    print "called the callback!"

root = Tk()

# create a menu
menu = Menu(root)
root.config(menu=menu)

filemenu = Menu(menu)
menu.add_cascade(label="LUT", menu=filemenu)
filemenu.add_command(label="East Pacific", command=lambda:openfile(0))
filemenu.add_command(label="NW Atlantic", command=lambda:openfile(1))


image_menu = Menu(menu)
menu.add_cascade(label="Rrs", command=rrs_file)

run_menu = Menu(menu)
menu.add_cascade(label="Run", command = make_comp)

quitmenu = Menu(menu)
menu.add_cascade(label="Quit", command=root.destroy)

#x = openfile(2)

mainloop()


I can not figure out how to pass get the lut and rrs parameters that I have defined in the class objects?

I need help !!!

 Thank you very much in advance.

    Emmanuel

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Firat Ozgul | 22 Sep 2010 21:53
Picon

Re: (no subject)

Hello,

I modified your code to make it work:

http://paste-it.net/public/m46ae5d/

Certainly, to be able to re-write the code, I made some assumptions and guesses about your original intentions. Just check the code to see if it is close to what you want.

Firat

2010/9/21 Devred, Emmanuel <Emmanuel.Devred <at> dfo-mpo.gc.ca>

Hello,
I am a total beginner with python and tkinter and I am having a hard time getting my program working, I think the problem come from passing variables.

I would like to have a menu that would with three main buttons, the first one (LUT) let me chosse between two files, the second button (rrs) opens a browser to choose a file and the third button would run a program (or function) that makes some computation between the two files open with button 1 and button 2,

Here is what I have written

from Tkinter import *
from tkFileDialog   import askopenfilename
import numpy as np


class openfile():
    def __init__(self, yn):
        if yn == 0 : self.lut = np.loadtxt("C:\python26\LUTnpdi_chile",dtype=np.float,skiprows=1)
        if yn == 1 : self.lut = np.loadtxt("C:\python26\LUTnpdi_nwa",dtype=np.float,skiprows=1)
        if yn == 2 : filename = askopenfilename(filetypes=[("allfiles","*"),("pythonfiles","*.py")])
        if yn == 2 : self.lut = np.loadtxt(filename,dtype=np.float,skiprows=1)

Class rrs_file(self,rrs):
    filename = askopenfilename(filetypes=[("allfiles","*"),("pythonfiles","*.py")])
    rrs = np.loadtxt(filename,dtype=np.float,skiprows=1)
   
def make_comp():
    result = self.lut[1,2] * rrs[1,2]
    print result
   
def callback():
    print "called the callback!"

root = Tk()

# create a menu
menu = Menu(root)
root.config(menu=menu)

filemenu = Menu(menu)
menu.add_cascade(label="LUT", menu=filemenu)
filemenu.add_command(label="East Pacific", command=lambda:openfile(0))
filemenu.add_command(label="NW Atlantic", command=lambda:openfile(1))


image_menu = Menu(menu)
menu.add_cascade(label="Rrs", command=rrs_file)

run_menu = Menu(menu)
menu.add_cascade(label="Run", command = make_comp)

quitmenu = Menu(menu)
menu.add_cascade(label="Quit", command=root.destroy)

#x = openfile(2)

mainloop()


I can not figure out how to pass get the lut and rrs parameters that I have defined in the class objects?

I need help !!!

 Thank you very much in advance.

    Emmanuel


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Hèlen Grives | 23 Sep 2010 08:55
Picon
Favicon

tkinter module

Hi,

I'm a newbie in programming (2 weeks) and I use a windows vista 32 computer.
I've currently installed the phyton - 3.2.a2.msi file. Previciously I used
versions 2.7 and 3.0 and 3.1.2. But no one gets the tkinter module to start. All
the previous releases are uninstalled. However I don't know how to get around
this problem quickly. My goal is to go back to the last 3.1.2 version and get it
to work properly. I hope you have any suggestions that are not too difficult
without a lot of knowledge.
Firat Ozgul | 23 Sep 2010 09:48
Picon

Re: tkinter module

Hello,

Until Python's 3.0 version, the name of the Tkinter module was "Tkinter". Therefore we used to import this module as:

>>> import Tkinter

Starting from Python 3.0, the name of this module is "tkinter". So you should issue the following command to import the module:

>>> import tkinter

Normally, Tkinter module is part of the Windows Python installer. You do not need to install anything special to make Tkinter work under Windows.

Just tell us what the output of this command in your system is:

>>> import sys
>>> sys.version

2010/9/23 Hèlen Grives <helengrives <at> hotmail.com>
Hi,

I'm a newbie in programming (2 weeks) and I use a windows vista 32 computer.
I've currently installed the phyton - 3.2.a2.msi file. Previciously I used
versions 2.7 and 3.0 and 3.1.2. But no one gets the tkinter module to start. All
the previous releases are uninstalled. However I don't know how to get around
this problem quickly. My goal is to go back to the last 3.1.2 version and get it
to work properly. I hope you have any suggestions that are not too difficult
without a lot of knowledge.

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Gmane