472,958 Members | 2,358 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Pmw problem in cygwin with Tkinter

I have a Tkinter app running on cygwin. It includes a Test menu item
that does nothing more than fetch a directory listing and display it
in a Toplevel window (I'd use a tkMessageBox showinfo widget, but for
some reason the text is invisible on cygwin).

After I close the Toplevel widget, all of the menus in my app behave
as though they have no contents to them, i..e I can press on the File
menu button, and see it depress, but the Exit submenu does not appear
(and neither do any of the other menus' submenus). However, a Quit
button in my status bar does respond, so the problem lies with the
menu.

Below are two apps that illustrate the problem. It's obvious that the
problem is with Pmw, and in particular with the menubar widget. The
first test app uses Pmw, and displays the problem behaviour. The
second test app uses basic Tk menus, and does not have a problem.

Any clues?

---
#test_subprocess3.py

from Tkinter import *

import os, sys
import subprocess

programHome = '/cygdrive/c/programs'
sys.path[:0] = [programHome]
try:
import Pmw
except ImportError:
print 'I need to have Pmw widget set installed in c:\\Programs\\Pmw'
sys.exit("missing Pmw")

class PumpAdmin(Pmw.MegaWidget):
def __init__(self, parent): #master=None):
Pmw.MegaWidget.__init__(self, parent)
#Frame.__init__(self, master, relief=SUNKEN, bd=2)
self.parent = parent

def drawGui(self):
'''draw the application'''

# Create the Balloon.
self.balloon = Pmw.Balloon(self.parent)

#---------- Menu bar ---------------

if 1:
menuBar=Pmw.MenuBar(self.parent, hull_relief='raised',
hull_borderwidth=1)
menuBar.pack(fill='x')
self.menuBar = menuBar

menuBar.addmenu('File', 'Close this window or exit')
menuBar.addmenuitem('File', 'command', 'Exit the
application', command=root.destroy, label='Exit')

menuBar.addmenu('Test', 'Test new features')
menuBar.addmenuitem('Test', 'command', 'Directory
listing', command=self.dir_list, label='Directory List')

# ------- Paned widget (central part of main window) -------

if 1:
panedWidget = Pmw.PanedWidget(self.parent,
orient = 'vertical', hull_height = 250, hull_width = 500)
self.panedWidget = panedWidget
self.panedWidget.add('results', min = 0.05)
self.panedWidget.pack(side='left', fill = 'both', expand = 1)

self.results =
Pmw.ScrolledText(self.panedWidget.pane('results'), text_wrap = 'none')
self.results.pack(fill = 'both', expand = 1)

# ----------------------- Status Bar --------------------------

if 1:
self.panedWidget.add('status', min = 0.05)
frmS = Frame(self.panedWidget.pane('status'))
self.frmS = frmS
frmS.pack(fill='x', expand=1)
labSpaceL = Label(frmS, text = ' ')
labSpaceR = Label(frmS, text = ' ')
labSystem = Button(frmS, text = 'Quit', command=root.destroy)
self.labSystem = labSystem
labSpaceL.pack(side='left')
self.labSystem.pack(side='left', fill='both',expand=0)
labSpaceR.pack(side='right')

def dir_list(self):
'''provide a listing of files in a directory'''
curdir = os.getcwd()
try:
p = subprocess.Popen(['ls',' -l'], bufsize=2048,
shell=True, close_fds=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(child_stdin, dirlist, retcode) = (p.stdin, p.stdout, p.stderr)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", retcode
print 'error'
self.myshowerror("Error","Sorry, couldn't get a
directory listing")
else:
print 'no error'
#print dirlist
msgList = []
for dir in dirlist:
#print dir
msgList.append(dir)
msg = ''.join(msgList)
#print msg
print 'got to 1'
self.myshowinfo("Directory Listing for %s" % curdir, msg)
print 'got to 2'
#self.drawMenu()
except OSError,e:
print >>sys.stderr, "Execution failed:", e

def mymessage(self, title, msg, msgType='info'):
'''a workalike for the tkMessageBox showinfo since the former
results in invisible text in cygwin'''
top = Toplevel()
top.title(title)
t = Label(top, text='\n%s\n' % msgType.upper())
t.pack()
l = Label(top, text=msg)
l.pack()
b = Button(top,text="Ok", command=top.destroy)
b.pack()

def myshowinfo(self, title='', msg=''):
'''a workalike for the tkMessageBox showinfo since the former
results in invisible text in cygwin'''
self.mymessage(title, msg,'info')
root.focus_set()
root.update()

if __name__ == '__main__':
if 1:
root = Tk()
Pmw.initialise(root, size = 16, useTkOptionDb = 1)
root.geometry('500x400+100+100')
root.title("Test application")
app = PumpAdmin(root)
app.drawGui()
app.pack(fill = 'both', expand = 1)
root.deiconify()
root.update()
root.mainloop()

---
#test_subprocess2.py

from Tkinter import *

import os, sys
import subprocess

class AppUI(Frame):

def __init__(self, master=None):
Frame.__init__(self, master, relief=SUNKEN, bd=2)

def drawGui(self):
self.drawMenu()
self.drawCanvas()

def drawMenu(self):
self.menubar = Menu(self)
menu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="File", menu=menu)
menu.add_command(label="Exit", command=root.destroy)

menu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Test", menu=menu)
menu.add_command(label="Dir list", command=self.dir_list)
try:
self.master.config(menu=self.menubar)
except AttributeError:
# master is a toplevel window (Python 1.4/Tkinter 1.63)
self.master.tk.call(master, "config", "-menu", self.menubar)

def drawCanvas(self):
self.canvas = Canvas(self, bg="white", width=400, height=400,
bd=0, highlightthickness=0)
self.canvas.pack()

def dir_list(self):
'''provide a listing of files in a directory'''
#need to know which system to draw from
curdir = os.getcwd()
try:
#dirlist = subprocess.Popen('ls -l', shell=False,
bufsize=2048, stdout=subprocess.PIPE).stdout
#dirlist,retcode = subprocess.Popen('ls -l',
stdout=subprocess.PIPE).communicate()
#retcode = subprocess.call('ls -l', shell=False)
p = subprocess.Popen(['ls',' -l'], bufsize=2048,
shell=True, close_fds=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(child_stdin, dirlist, retcode) = (p.stdin, p.stdout, p.stderr)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", retcode
print 'error'
self.myshowerror("Error","Sorry, couldn't get a
directory listing")
else:
print 'no error'
#print dirlist
msgList = []
for dir in dirlist:
#print dir
msgList.append(dir)
msg = ''.join(msgList)
#print msg
print 'got to 1'
self.myshowinfo("Directory Listing for %s" % curdir, msg)
print 'got to 2'
self.drawMenu()
except OSError,e:
print >>sys.stderr, "Execution failed:", e

def mymessage(self, title, msg, msgType='info'):
'''a workalike for the tkMessageBox showinfo since the former
results in invisible text in cygwin'''
top = Toplevel()
top.title(title)
t = Label(top, text='\n%s\n' % msgType.upper())
t.pack()
l = Label(top, text=msg)
l.pack()
b = Button(top,text="Ok", command=top.destroy)
b.pack()

def myshowinfo(self, title='', msg=''):
'''a workalike for the tkMessageBox showinfo since the former
results in invisible text in cygwin'''
self.mymessage(title, msg,'info')
root.focus_set()
root.update()
root = Tk()
app = AppUI(root)
app.drawGui()
app.pack()
root.mainloop()
thanks,
--
Stewart Midwinter
st*****@midwinter.ca
st***************@gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1
Jan 5 '06 #1
0 2279

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jörg Maier | last post by:
Hey guys, i have a big problem using Tkinter and pexpect in cygwin. i try to program an winscp-like rsync Program for all posix Platforms (linux, macosx, cygwin). i got a class SslConnection...
0
by: dw | last post by:
Pehaba, does anyone knows how to install MySQLdb on cygwin? - test device: MySQLdb 0.9.2.0 targz + cygwin 1.5.7-cr-0x9e + python 2.3.3 on cygwin + mysql 4.0.17 win32 - modified setup.py's...
1
by: Laura Conrad | last post by:
I'm writing a GUI application in python, which will need to work on a Windows XP box. Mostly it does, but the feature where results are graphed in real time, which works fine on a debian LINUX...
1
by: Eric McRae | last post by:
I have created a somewhat complicated GUI which updates itself every 1/2 second by checking on several non-blocking sockets for data and modifying StringVars and/or canvas graphs when new...
0
by: denis | last post by:
Hello, Do you know if it is possible to use python + qt bindings in cygwin ? I've looked inside kde / cygwin. There is a package named qt-gcc-3 but I did'nt find the qt bindings for python :/ Is...
4
by: goberle | last post by:
I have installed the Cygwin package under WinXP. I am trying to insure that I have a reasonable development environment, and that things are working properly, by trying to compile and run the...
2
by: Steve Holden | last post by:
Is anyone aware of (a fix for) problems I'm having getting PIL 1.1.5 to create bitmaps using TrueType and openType fonts? When I create an image using the standard PIL fonts everything seems fine,...
0
by: gh14tq5 | last post by:
Hi, I've recently started learning python programming and have been experimenting with a few basic GUI programs. My work system is cygwin/Windows XP. I use X-windows in cygwin but when I run...
2
by: Stewart Midwinter | last post by:
this has me puzzled; I've created a small test app to show the problem I'm having. I want to use subprocess to execute system commands from inside a Tkinter app running under Cygwin. When I...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.