-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewpoproutereport.py
182 lines (149 loc) · 6.05 KB
/
viewpoproutereport.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#! /usr/bin/env python
#
# GUI module generated by PAGE version 4.7
# In conjunction with Tcl version 8.6
# Apr 24, 2016 03:11:37 AM
import sys
try:
from Tkinter import *
except ImportError:
from tkinter import *
try:
import ttk
py3 = 0
except ImportError:
import tkinter.ttk as ttk
py3 = 1
import viewpoproutereport_support
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
top = View_Popular_Route_Report (root)
viewpoproutereport_support.init(root, top)
root.mainloop()
w = None
def create_View_Popular_Route_Report(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = Toplevel (root)
top = View_Popular_Route_Report (w)
viewpoproutereport_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_View_Popular_Route_Report():
global w
w.destroy()
w = None
class View_Popular_Route_Report:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#d9d9d9' # X11 color: 'gray85'
self.style = ttk.Style()
if sys.platform == "win32":
self.style.theme_use('winnative')
self.style.configure('.',background=_bgcolor)
self.style.configure('.',foreground=_fgcolor)
self.style.configure('.',font="TkDefaultFont")
self.style.map('.',background=
[('selected', _compcolor), ('active',_ana2color)])
top.geometry("600x450+249+152")
top.title("View Popular Route Report")
self.style.configure('Treeview.Heading', font="TkDefaultFont")
self.Scrolledtreeview1 = ScrolledTreeView(top)
self.Scrolledtreeview1.place(relx=0.05, rely=0.07, relheight=0.6
, relwidth=0.78)
self.Scrolledtreeview1.configure(columns="Col1 Col2")
self.Scrolledtreeview1.heading("#0",text="Month")
self.Scrolledtreeview1.heading("#0",anchor="center")
self.Scrolledtreeview1.column("#0",width="112")
self.Scrolledtreeview1.column("#0",minwidth="20")
self.Scrolledtreeview1.column("#0",stretch="1")
self.Scrolledtreeview1.column("#0",anchor="w")
self.Scrolledtreeview1.heading("Col1",text="Train Number")
self.Scrolledtreeview1.heading("Col1",anchor="center")
self.Scrolledtreeview1.column("Col1",width="132")
self.Scrolledtreeview1.column("Col1",minwidth="20")
self.Scrolledtreeview1.column("Col1",stretch="1")
self.Scrolledtreeview1.column("Col1",anchor="w")
self.Scrolledtreeview1.heading("Col2",text="#reservations")
self.Scrolledtreeview1.heading("Col2",anchor="center")
self.Scrolledtreeview1.column("Col2",width="208")
self.Scrolledtreeview1.column("Col2",minwidth="20")
self.Scrolledtreeview1.column("Col2",stretch="1")
self.Scrolledtreeview1.column("Col2",anchor="w")
self.Button1 = Button(top)
self.Button1.place(relx=0.2, rely=0.8, height=26, width=57)
self.Button1.configure(activebackground="#d9d9d9")
self.Button1.configure(text='''Close''')
# The following code is added to facilitate the Scrolled widgets you specified.
class AutoScroll(object):
'''Configure the scrollbars for a widget.'''
def __init__(self, master):
# Rozen. Added the try-except clauses so that this class
# could be used for scrolled entry widget for which vertical
# scrolling is not supported. 5/7/14.
try:
vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview)
except:
pass
hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview)
#self.configure(yscrollcommand=self._autoscroll(vsb),
# xscrollcommand=self._autoscroll(hsb))
try:
self.configure(yscrollcommand=self._autoscroll(vsb))
except:
pass
self.configure(xscrollcommand=self._autoscroll(hsb))
self.grid(column=0, row=0, sticky='nsew')
try:
vsb.grid(column=1, row=0, sticky='ns')
except:
pass
hsb.grid(column=0, row=1, sticky='ew')
master.grid_columnconfigure(0, weight=1)
master.grid_rowconfigure(0, weight=1)
# Copy geometry methods of master (taken from ScrolledText.py)
if py3:
methods = Pack.__dict__.keys() | Grid.__dict__.keys() \
| Place.__dict__.keys()
else:
methods = Pack.__dict__.keys() + Grid.__dict__.keys() \
+ Place.__dict__.keys()
for meth in methods:
if meth[0] != '_' and meth not in ('config', 'configure'):
setattr(self, meth, getattr(master, meth))
@staticmethod
def _autoscroll(sbar):
'''Hide and show scrollbar as needed.'''
def wrapped(first, last):
first, last = float(first), float(last)
if first <= 0 and last >= 1:
sbar.grid_remove()
else:
sbar.grid()
sbar.set(first, last)
return wrapped
def __str__(self):
return str(self.master)
def _create_container(func):
'''Creates a ttk Frame with a given master, and use this new frame to
place the scrollbars and the widget.'''
def wrapped(cls, master, **kw):
container = ttk.Frame(master)
return func(cls, container, **kw)
return wrapped
class ScrolledTreeView(AutoScroll, ttk.Treeview):
'''A standard ttk Treeview widget with scrollbars that will
automatically show/hide as needed.'''
@_create_container
def __init__(self, master, **kw):
ttk.Treeview.__init__(self, master, **kw)
AutoScroll.__init__(self, master)
if __name__ == '__main__':
vp_start_gui()