[py-svn] r11023 - py/dist/py/test/tkinter
jan at codespeak.net
jan at codespeak.net
Fri Apr 22 16:22:14 CEST 2005
Author: jan
Date: Fri Apr 22 16:22:14 2005
New Revision: 11023
Modified:
py/dist/py/test/tkinter/tixgui.py
Log:
use Tkinter only / no Tix needed
Modified: py/dist/py/test/tkinter/tixgui.py
==============================================================================
--- py/dist/py/test/tkinter/tixgui.py (original)
+++ py/dist/py/test/tkinter/tixgui.py Fri Apr 22 16:22:14 2005
@@ -3,25 +3,29 @@
from py.__impl__.test.tkinter import util
Null = util.Null
-
import ScrolledText
from Tkinter import PhotoImage
-import Tix
-from Tkconstants import *
+import Tkinter
import re
import os
-class StatusBar(Tix.Frame):
+myfont = ('Helvetica', 9, 'normal')
+
+class StatusBar(Tkinter.Frame):
+
+ font = ('Helvetica', 10, 'normal')
def __init__(self, master=None, **kw):
if master is None:
master = Tk()
- apply(Tix.Frame.__init__, (self, master), kw)
+ Tkinter.Frame.__init__(self, master, **kw)
self.labels = {}
- def set_label(self, name, text='', side=LEFT):
+ def set_label(self, name, text='', side=Tkinter.LEFT):
if not self.labels.has_key(name):
- label = Tix.Label(self, bd=1, relief=SUNKEN, anchor=W)
+ label = Tkinter.Label(self, bd=1, relief=Tkinter.SUNKEN,
+ anchor=Tkinter.W,
+ font=self.font)
label.pack(side=side)
self.labels[name] = label
else:
@@ -48,30 +52,43 @@
else:
self.set_label('Time', '%0.2f seconds' % 0.0)
-class ReportListBox(Tix.LabelFrame):
+class ReportListBox(Tkinter.LabelFrame):
+
+ font = myfont
def __init__(self, *args, **kwargs):
- Tix.LabelFrame.__init__(self, *args, **kwargs)
+ Tkinter.LabelFrame.__init__(self, *args, **kwargs)
self.callback = Null()
self.data = {}
+ self.label = Tkinter.Label(self)
+ self.label.configure(font = self.font, width = 80, anchor = Tkinter.W)
+ self.configure(labelwidget=self.label)
self.createwidgets()
self.label.configure(text = 'Idle')
+ self.configure(font = myfont)
+
def createwidgets(self):
- self.listbox = Tix.Listbox(self.frame, foreground='red',
- selectmode=SINGLE)
+ self.listbox = Tkinter.Listbox(self, foreground='red',
+ selectmode=Tkinter.SINGLE, font = self.font)
- self.scrollbar = Tix.Scrollbar(self.frame, command=self.listbox.yview)
- self.scrollbar.pack(side = RIGHT, fill = Y, anchor = N)
- self.listbox.pack(side = LEFT, fill = BOTH, expand = YES, anchor = NW)
- self.listbox.configure(yscrollcommand = self.scrollbar.set)
+ self.scrollbar = Tkinter.Scrollbar(self, command=self.listbox.yview)
+ self.scrollbar.pack(side = Tkinter.RIGHT, fill = Tkinter.Y,
+ anchor = Tkinter.N)
+ self.listbox.pack(side = Tkinter.LEFT,
+ fill = Tkinter.BOTH, expand = Tkinter.YES,
+ anchor = Tkinter.NW)
+ self.listbox.configure(yscrollcommand = self.scrollbar.set,
+ bg = 'White',selectbackground= 'Red',
+ takefocus= Tkinter.YES)
def set_callback(self, callback):
self.callback = callback
self.listbox.bind('<Double-1>', self.do_callback)
def do_callback(self, *args):
- report_ids = [self.data[self.listbox.get(int(item))] for item in self.listbox.curselection()]
+ report_ids = [self.data[self.listbox.get(int(item))]
+ for item in self.listbox.curselection()]
for report_id in report_ids:
self.callback(report_id)
@@ -87,13 +104,13 @@
if len(failed_childs + skipped_childs) == len(self.data.keys()):
return
old_selection = [int(sel) for sel in self.listbox.curselection()]
- self.listbox.delete(0, END)
+ self.listbox.delete(0, Tkinter.END)
self.data = {}
for report_id in failed_childs + skipped_childs:
report = repository.find(report_id)
label = '%s: %s' % (report.status, report.label)
self.data[label] = report.full_id
- self.listbox.insert(END, label)
+ self.listbox.insert(Tkinter.END, label)
for index in old_selection:
try:
self.listbox.select_set(index)
@@ -102,10 +119,25 @@
-
+class LabelEntry(Tkinter.Frame):
+
+ font = myfont
+
+ def __init__(self, *args, **kwargs):
+ Tkinter.Frame.__init__(self, *args, **kwargs)
+ self.label = Tkinter.Label(self)
+ self.label.configure(font = self.font)
+ self.label.pack(side = Tkinter.LEFT)
+ self.entry = Tkinter.Entry(self)
+ self.entry.configure(font = self.font)
+ self.entry.pack(side = Tkinter.LEFT, expand = Tkinter.YES,
+ fill = Tkinter.X)
+
class TixGui:
+ font = ('Helvetica', 9, 'normal')
+
def __init__(self, parent, config):
self._parent = parent
self._config = config
@@ -117,49 +149,50 @@
self.timer_update()
def createwidgets(self):
- self._buttonframe = Tix.Frame(self._parent)
- self._entry = Tix.FileEntry(self._buttonframe, label = 'Tests:',
- command = self.start_tests)
- self._entry.pack(side = LEFT, fill = X, expand = YES)
- self._stop = Tix.Button(self._buttonframe, text = 'Stop',
- command = self.stop)
- self._stop.pack(side = RIGHT)
- self._run = Tix.Button(self._buttonframe, text = 'Run',
- command = self._entry.invoke)
- self._run.pack(side = RIGHT)
- self._buttonframe.pack(side = TOP, fill = X)
+ self._buttonframe = Tkinter.Frame(self._parent)
+ self._entry = LabelEntry(self._buttonframe)
+ self._entry.label.configure(text = 'Enter test name:')
+ self._entry.entry.bind('<Return>', self.start_tests)
+ self._entry.pack(side = Tkinter.LEFT, fill = Tkinter.X,
+ expand = Tkinter.YES)
+ self._stop = Tkinter.Button(self._buttonframe, text = 'Stop',
+ command = self.stop, font = self.font)
+ self._stop.pack(side = Tkinter.RIGHT)
+ self._run = Tkinter.Button(self._buttonframe, text = 'Run',
+ command = self.start_tests, font = self.font)
+ self._run.pack(side = Tkinter.RIGHT)
+ self._buttonframe.pack(side = Tkinter.TOP, fill = Tkinter.X)
self._reportlist = ReportListBox(self._parent)
- self._reportlist.label.configure(width=80,anchor=W )
- self._reportlist.pack(side = TOP, fill = BOTH, expand = YES)
+ self._reportlist.pack(side = Tkinter.TOP, fill = Tkinter.BOTH,
+ expand = Tkinter.YES)
self._reportlist.set_callback(self.show_error)
- #self._tree = reporttree.ReportTree(self._parent, backend = self.backend)
- #self._tree.pack(side = TOP, fill = BOTH, expand = YES)
self._statusbar = StatusBar(self._parent)
- self._statusbar.pack(side=BOTTOM, fill=X)
+ self._statusbar.pack(side= Tkinter.BOTTOM, fill=Tkinter.X)
self.update_status(self.backend.get_repository())
def show_error(self, report_id):
report = self.backend.get_repository().find(report_id)
- window = Tix.Toplevel(self._parent)
+ window = Tkinter.Toplevel(self._parent)
window.title(report.label)
window.protocol('WM_DELETE_WINDOW', window.quit)
- Tix.Label(window, text='%s: %s' % (report.status, report.label),
- foreground="red", justify=LEFT).pack(anchor=W)
+ Tkinter.Label(window, text='%s: %s' % (report.status, report.label),
+ foreground="red", justify=Tkinter.LEFT).pack(anchor=Tkinter.W)
text = ScrolledText.ScrolledText(window)
- text.tag_config('sel', relief=FLAT)
- text.insert(END, report.error_report)
+ text.configure(bg = 'White', font = ('Helvetica', 11, 'normal'))
+ text.tag_config('sel', relief=Tkinter.FLAT)
+ text.insert(Tkinter.END, report.error_report)
if len(report.error_report.splitlines()) < 20:
text.config(height=len(report.error_report.splitlines()) + 5)
- text.yview_pickplace(END)
- text['state'] = DISABLED
+ text.yview_pickplace(Tkinter.END)
+ text['state'] = Tkinter.DISABLED
text['cursor'] = window['cursor']
self.attacheditorhotspots(text)
- text.pack(expand=1, fill=BOTH)
- ##
- b = Tix.Button(window, text="Close",
- command=window.quit)
- b.pack(side=BOTTOM)
+ text.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)
+
+ b = Tkinter.Button(window, text="Close",
+ command=window.quit, font = self.font)
+ b.pack(side=Tkinter.BOTTOM)
b.focus_set()
window.bind('<Key-Return>', lambda e, w=window: w.quit())
window.mainloop()
@@ -169,7 +202,7 @@
# Attach clickable regions to a Text widget.
filelink = re.compile(r"""\[(?:testcode\s*:)?\s*(.+):(\d+)\]""")
skippedlink = re.compile(r"""in\s+(/.*):(\d+)\s+""")
- lines = text.get('1.0', END).splitlines(1)
+ lines = text.get('1.0', Tkinter.END).splitlines(1)
if not lines:
return
tagname = ''
@@ -211,6 +244,8 @@
self._parent.after(100, self.timer_update)
def start_tests(self, dont_care_event=None):
+ if self.backend.running:
+ return
paths = [path.strip() for path in self._entry.entry.get().split(',')]
self.backend.set_messages_callback(self.messages_callback)
self.backend.set_message_callback(self.message_callback)
@@ -246,7 +281,7 @@
def set_paths(self, paths):
self._paths = paths
- self._entry.entry.insert(END, ', '.join(paths))
+ self._entry.entry.insert(Tkinter.END, ', '.join(paths))
def stop(self):
self.backend.shutdown()
@@ -264,7 +299,7 @@
self.config = config
def main(self, paths):
- root = Tix.Tk()
+ root = Tkinter.Tk()
tixgui = TixGui(root, self.config)
tixgui.set_paths(paths)
root.protocol('WM_DELETE_WINDOW', tixgui.shutdown)
More information about the pytest-commit
mailing list