Advertisement
Uno-Dan

Untitled

May 6th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.63 KB | None | 0 0
  1.     def forms_test_page(self):
  2.         wm = self.window_manager
  3.         page_name = 'Forms Test Page'
  4.         pg, page_cached = wm.page(page_name)
  5.  
  6.         if not page_cached:
  7.             pg.config(bg='purple')
  8.  
  9.             pane = PanedWindow(pg, bg=self.__sidebar_bg, borderwidth=0, orient='vertical')
  10.             pane.grid(sticky='NSEW')
  11.  
  12.             canvas1 = Canvas(pane, borderwidth=0, highlightthickness=0)
  13.             canvas1.rowconfigure(0, weight=1)
  14.             canvas1.columnconfigure(0, weight=1)
  15.             canvas1.config(bg='purple')
  16.             pane.add(canvas1)
  17.  
  18.             canvas = Canvas(pane, borderwidth=0, highlightthickness=0)
  19.             canvas.rowconfigure(0, weight=1)
  20.             canvas.columnconfigure(0, weight=1)
  21.             pane.add(canvas)
  22.  
  23.             frame = Frame(canvas)
  24.             frame.rowconfigure(1, weight=1)
  25.             frame.columnconfigure(0, weight=1)
  26.             frame.grid(row=0, column=0, sticky='NSEW')
  27.  
  28.             f1 = Frame(frame)
  29.             f1.rowconfigure(0, weight=1)
  30.             f1.columnconfigure(0, weight=1)
  31.             f1.grid(row=0, column=0, sticky='NEW')
  32.  
  33.             f2 = Frame(frame)
  34.             f2.rowconfigure(0, weight=1)
  35.             f2.columnconfigure(0, weight=1)
  36.             f2.grid(row=1, column=0, sticky='NSEW')
  37.  
  38.             Label(
  39.                 f1,
  40.                 text='Season Win/Loss',
  41.                 font=("Helvetica", 15),
  42.                 bg='white'
  43.             ).grid(sticky='EW')
  44.  
  45.             columns = (
  46.                 {'id': '#0', 'anchor': 'w'},
  47.                 {'id': 'id'},
  48.                 {'id': 'starttime'},
  49.                 {'id': 'endtime'},
  50.                 {'id': 'totaltime'},
  51.                 {'id': 'minutes'},
  52.                 {'id': 'team1', 'width': 150},
  53.                 {'id': 'team2', 'width': 150},
  54.                 {'id': 'winner', 'width': 150}
  55.             )
  56.             headings = (
  57.                 {'id': '#0', 'text': '#', 'anchor': 'w'},
  58.                 {'id': 'id', 'text': 'ID'},
  59.                 {'id': 'starttime', 'text': 'Start Time'},
  60.                 {'id': 'endtime', 'text': 'End Time'},
  61.                 {'id': 'totaltime', 'text': 'Total Time'},
  62.                 {'id': 'minutes', 'text': 'Minutes'},
  63.                 {'id': 'team1', 'text': 'Team1'},
  64.                 {'id': 'team2', 'text': 'Team2'},
  65.                 {'id': 'winner', 'text': 'Winner'}
  66.             )
  67.  
  68.             table_data = self.table_data
  69.             table = TableView(f2, headings, columns)
  70.  
  71.             table['show'] = 'headings'
  72.             for i, row in enumerate(table_data, 1):
  73.                 tag = 'even' if i % 2 else 'odd'
  74.                 table.insert('', 'end', values=row, tags=(tag,))
  75.  
  76.             def save():
  77.                 messagebox.showinfo('Test', 'Save popup')
  78.  
  79.             def delete():
  80.                 messagebox.showinfo('Test', 'Delete popup')
  81.  
  82.             def new():
  83.                 messagebox.showinfo('Test', 'New popup')
  84.  
  85.             def search():
  86.                 messagebox.showinfo('Test', 'Search popup')
  87.  
  88.             bindings = (
  89.                 ('game', 'Game', 'LabelFrame', (
  90.                     ('id', 'Number', 'Entry', None, 0, 0, 5, '', 'normal'),
  91.                     ('winner', 'Winning Team', 'Entry', None, 0, 1, 30, '', 'normal'),
  92.                 ), 0, 0),
  93.                 ('teams', 'Teams', 'LabelFrame', (
  94.                     ('team1', 'Home Team', 'Entry', None, 0, 0, 30, '', 'normal'),
  95.                     ('team2', 'Visitor Team', 'Entry', None, 1, 0, 30, '', 'normal'),
  96.                 ), 1, 0),
  97.                 ('times', 'Times', 'LabelFrame', (
  98.                     ('starttime', 'Start', 'Entry', None, 0, 0, 10, '', 'normal'),
  99.                     ('endtime', 'Finish', 'Entry', None, 0, 1, 10, '', 'normal'),
  100.                     ('totaltime', 'Total Time', 'Entry', None, 1, 0, 10, '', 'normal'),
  101.                     ('minutes', 'Minutes Played', 'Entry', None, 1, 1, 10, '', 'normal'),
  102.                 ), 1, 1,),
  103.                 ('buttons', '', 'LabelFrame', (
  104.                     ('save', 'Save', 'Button', save, 0, 0, 10, 'normal'),
  105.                     ('delete', 'Delete', 'Button', delete, 0, 1, 10, 'normal'),
  106.                     ('new', 'New', 'Button', new, 0, 2, 10, 'normal'),
  107.                     ('search', 'Search', 'Button', search, 0, 3, 10, 'normal'),
  108.                 ), 2, 0),
  109.             )
  110.  
  111.             form = Form(canvas1, table, bindings)
  112.             form.group('game').grid(sticky='EW', columnspan=2)
  113.             form.group('buttons').grid(sticky='EW', columnspan=2)
  114.  
  115.             for __, item in form.groups().items():
  116.                 item.grid(padx=2, pady=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement