Advertisement
Uno-Dan

Untitled

Nov 11th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 57.66 KB | None | 0 0
  1.  
  2. from tkinter import messagebox
  3.  
  4. from tkapp.base import App
  5. from tkapp.constants import LAST_ROW, LAST_COLUMN
  6.  
  7.  
  8. def main():
  9.     defaults = {
  10.         'window1': {
  11.             'type': 'Frame',
  12.             'window_title': 'Demo App1',
  13.             'auto_save': True,
  14.             'auto_start': False,
  15.             'scrollbars': False,
  16.             'save_geometry': True,
  17.             'sticky': 'nsew',
  18.             'content': {
  19.                 'type': 'PanedWindow',
  20.                 'orient': 'horizontal',
  21.                 'sashwidth': 2,
  22.                 'background': '#000000',
  23.                 'sticky': 'nsew',
  24.                 'left_pane': {
  25.                     'type': 'Frame',
  26.                     'treeview': {
  27.                         'type': 'Treeview',
  28.                         'rowspan': 9899,
  29.                         'column': 0,
  30.                         'label': 'Pages',
  31.                         'scrollbars': 'vertical',
  32.                         'items': {
  33.                             'demos': {
  34.                                 'label': 'Demos',
  35.                                 'children': {
  36.                                     '3d_demo': {
  37.                                         'label': '3D Demo'
  38.                                     },
  39.                                     'animation_demo': {
  40.                                         'label': 'Animation Demo'
  41.                                     },
  42.                                     'animation_demo_two': {
  43.                                         'label': 'Animation Demo Two'
  44.                                     }
  45.                                 }
  46.                             },
  47.                             'statistics': {
  48.                                 'label': 'Statistics',
  49.                                 'children': {
  50.                                     'season_win_loss': {
  51.                                         'label': 'Season Win\\Loss'
  52.                                     },
  53.                                     'season_game_times': {
  54.                                         'label': 'Season Game Times'
  55.                                     }
  56.                                 }
  57.                             },
  58.                             'templates': {
  59.                                 'label': 'Templates',
  60.                                 'children': {
  61.                                     'template1': {
  62.                                         'label': 'Template 1'
  63.                                     },
  64.                                     'template2': {
  65.                                         'label': 'Template 2'
  66.                                     },
  67.                                     'template3': {
  68.                                         'label': 'Template 3'
  69.                                     }
  70.                                 }
  71.                             },
  72.                         },
  73.                         'sticky': 'NSEW'
  74.                     }
  75.                 },
  76.                 'middle_pane': {
  77.                     'type': 'Frame',
  78.                     'rowconfigure': LAST_ROW,
  79.                     'entry1': {
  80.                         'type': 'Entry',
  81.                         'label': ' Label 1 ',
  82.                         'label_anchor': 'w'
  83.                     },
  84.                     'load_defaults': {
  85.                         'type': 'Checkbutton',
  86.                         'row': 3,
  87.                         'label': 'Load Defaults',
  88.                         'value': 1,
  89.                     },
  90.                     'radio_buttons': {
  91.                         'type': 'Radiobutton',
  92.                         'row': 4,
  93.                         'value': 1,
  94.                         'items': ('Button1', 'Button2')
  95.                     },
  96.                     'combobox': {
  97.                         'type': 'Combobox',
  98.                         'row': 5,
  99.                         'items': ('', 'Your Item1', 'Your Item2')
  100.                     },
  101.                     'spinbox': {
  102.                         'row': 6,
  103.                         'column': 0,
  104.                         'columnspan': 9900,
  105.                         'pady': 5,
  106.                         'type': 'Spinbox',
  107.                         'label': 'Spinbox',
  108.                         'label_anchor': 'w',
  109.                         'to': 10,
  110.                         'from_': 0,
  111.                         'value': '7',
  112.                         'wrap': True,
  113.                         'sticky': 'w',
  114.                     },
  115.                     'progress': {
  116.                         'type': 'Frame',
  117.                         'row': 7,
  118.                         'padx': 5,
  119.                         'pady': 5,
  120.                         'sticky': 'w',
  121.                         'columnconfigure': 1,
  122.                         'start': {
  123.                             'type': 'Button',
  124.                             'padx': [0, 5],
  125.                             'text': 'Start Process',
  126.                             'sticky': 'W'
  127.                         },
  128.                         'bar': {
  129.                             'type': 'Progressbar',
  130.                             'column': 1,
  131.                             'sticky': 'EW',
  132.                             'value': 0,
  133.                             'maximum': 50000,
  134.                             'refresh_rate': 50,
  135.                         }
  136.                     },
  137.                     'sep1': {
  138.                         'type': 'Separator',
  139.                         'row': 8,
  140.                         'pady': 5,
  141.                         'columnspan': LAST_COLUMN,
  142.                         'orient': 'horizontal',
  143.                         'sticky': 'EW'
  144.                     },
  145.                     'notebook': {
  146.                         'type': 'Notebook',
  147.                         'row': 9,
  148.                         'sticky': 'NW',
  149.                         'items': {
  150.                             'one': {
  151.                                 'label': 'One',
  152.                                 'content': {
  153.                                     'type': 'Frame',
  154.                                     'sticky': 'NEW',
  155.                                     'wrap': {
  156.                                         'type': 'LabelFrame',
  157.                                         'label': 'Group Title',
  158.                                         'sticky': 'NEW',
  159.                                         'padx': 5,
  160.                                         'pady': 5,
  161.                                         'ipadx': 5,
  162.                                         'ipady': 5,
  163.                                         'entry': {
  164.                                             'type': 'Entry',
  165.                                             'columnspan': 9900,
  166.                                             'label': 'Entry Label 3',
  167.                                             'label_width': 12,
  168.                                             'label_anchor': 'e',
  169.                                             'value': 'My Entry Text'
  170.                                         },
  171.                                         'quantity': {
  172.                                             'type': 'Combobox',
  173.                                             'row': 1,
  174.                                             'columnspan': 9900,
  175.                                             'pady': [
  176.                                                 5,
  177.                                                 0
  178.                                             ],
  179.                                             'label': 'Quantity',
  180.                                             'label_width': 12,
  181.                                             'label_anchor': 'e',
  182.                                             'items': [
  183.                                                 'One',
  184.                                                 'Two',
  185.                                                 'Three',
  186.                                                 'Four',
  187.                                                 'Five'
  188.                                             ],
  189.                                             'value': 1
  190.                                         },
  191.                                         'spinbox': {
  192.                                             'row': 2,
  193.                                             'column': 0,
  194.                                             'columnspan': 9900,
  195.                                             'pady': 5,
  196.                                             'type': 'Spinbox',
  197.                                             'label': 'Spinbox',
  198.                                             'label_width': 12,
  199.                                             'label_anchor': 'e',
  200.                                             'to': 10,
  201.                                             'from_': 0,
  202.                                             'value': '7',
  203.                                             'wrap': True
  204.                                         },
  205.                                         'sep1': {
  206.                                             'type': 'Separator',
  207.                                             'row': 3,
  208.                                             'pady': [
  209.                                                 5,
  210.                                                 0
  211.                                             ],
  212.                                             'columnspan': 9900,
  213.                                             'orient': 'horizontal',
  214.                                             'columnconfigure': 1,
  215.                                             'sticky': 'EW'
  216.                                         },
  217.                                         'checkbutton': {
  218.                                             'type': 'Checkbutton',
  219.                                             'row': 4,
  220.                                             'label': 'Check Me',
  221.                                             'label_width': 12,
  222.                                             'label_anchor': 'e',
  223.                                             'value': 0,
  224.                                             'onvalue': 1,
  225.                                             'highlightthickness': 0
  226.                                         },
  227.                                         'sep2': {
  228.                                             'type': 'Separator',
  229.                                             'row': 4,
  230.                                             'column': 1,
  231.                                             'orient': 'vertical',
  232.                                             'sticky': 'NS'
  233.                                         },
  234.                                         'radiobutton': {
  235.                                             'type': 'Radiobutton',
  236.                                             'row': 4,
  237.                                             'column': 2,
  238.                                             'items': [
  239.                                                 'one',
  240.                                                 'two',
  241.                                                 'three'
  242.                                             ],
  243.                                             'value': 0,
  244.                                             'sticky': 'w'
  245.                                         }
  246.                                     },
  247.                                     'progress': {
  248.                                         'type': 'Frame',
  249.                                         'row': 2,
  250.                                         'padx': 5,
  251.                                         'pady': 5,
  252.                                         'columnconfigure': 1,
  253.                                         'start': {
  254.                                             'type': 'Button',
  255.                                             'padx': [
  256.                                                 0,
  257.                                                 5
  258.                                             ],
  259.                                             'text': 'Start Process',
  260.                                             'sticky': 'W'
  261.                                         },
  262.                                         'bar': {
  263.                                             'type': 'Progressbar',
  264.                                             'column': 1,
  265.                                             'sticky': 'EW',
  266.                                             'value': 0,
  267.                                             'maximum': 500000,
  268.                                             'refresh_rate': 50,
  269.                                         }
  270.                                     },
  271.                                     'lscale': {
  272.                                         'type': 'Label',
  273.                                         'row': 3,
  274.                                         'value': 0,
  275.                                         'sticky': 'EW'
  276.                                     },
  277.                                     'scale': {
  278.                                         'type': 'Scale',
  279.                                         'row': 4,
  280.                                         'padx': [
  281.                                             5,
  282.                                             0
  283.                                         ],
  284.                                         'to': 100,
  285.                                         'from_': 0,
  286.                                         'length': 300,
  287.                                         'value': 51
  288.                                     }
  289.                                 }
  290.                             },
  291.                             'two': {
  292.                                 'label': 'Two',
  293.                                 'content': {
  294.                                     'type': 'LabelFrame',
  295.                                     'label': 'Group Title',
  296.                                     'padx': 5,
  297.                                     'pady': 5,
  298.                                     'ipadx': 5,
  299.                                     'ipady': 5,
  300.                                     'sticky': 'NEW',
  301.                                     'columnconfigure': 1,
  302.                                     'entry': {
  303.                                         'type': 'Entry',
  304.                                         'columnspan': 9900,
  305.                                         'label': 'Entry Label 3',
  306.                                         'label_anchor': 'e',
  307.                                         'value': 'My Entry Text'
  308.                                     },
  309.                                     'spinbox': {
  310.                                         'row': 2,
  311.                                         'column': 0,
  312.                                         'columnspan': 9900,
  313.                                         'pady': 5,
  314.                                         'type': 'Spinbox',
  315.                                         'label': 'Spinbox',
  316.                                         'label_anchor': 'e',
  317.                                         'to': 10,
  318.                                         'from_': 0,
  319.                                         'value': '7',
  320.                                         'wrap': True
  321.                                     },
  322.                                     'checkbutton': {
  323.                                         'type': 'Checkbutton',
  324.                                         'row': 3,
  325.                                         'label': 'Check Me',
  326.                                         'label_anchor': 'e',
  327.                                         'value': 0,
  328.                                         'onvalue': 1
  329.                                     },
  330.                                     'sep1': {
  331.                                         'type': 'Separator',
  332.                                         'row': 3,
  333.                                         'column': 1,
  334.                                         'orient': 'vertical',
  335.                                         'sticky': 'NS'
  336.                                     },
  337.                                     'radiobutton': {
  338.                                         'type': 'Radiobutton',
  339.                                         'row': 3,
  340.                                         'column': 2,
  341.                                         'items': [
  342.                                             'one',
  343.                                             'two',
  344.                                             'three'
  345.                                         ],
  346.                                         'value': 0,
  347.                                         'sticky': 'w'
  348.                                     },
  349.                                     'sep2': {
  350.                                         'type': 'Separator',
  351.                                         'row': 4,
  352.                                         'pady': [
  353.                                             5,
  354.                                             0
  355.                                         ],
  356.                                         'columnspan': 9900,
  357.                                         'orient': 'horizontal',
  358.                                         'columnconfigure': 1,
  359.                                         'sticky': 'EW'
  360.                                     },
  361.                                     'tabs': {
  362.                                         'row': 5,
  363.                                         'column': 0,
  364.                                         'columnspan': 9900,
  365.                                         'pady': [
  366.                                             5,
  367.                                             0
  368.                                         ],
  369.                                         'type': 'Notebook',
  370.                                         'sticky': 'NSEW',
  371.                                         'items': {
  372.                                             'one': {
  373.                                                 'label': 'Tab1',
  374.                                                 'content': {
  375.                                                     'type': 'LabelFrame',
  376.                                                     'label': 'Group Title',
  377.                                                     'padx': 5,
  378.                                                     'pady': 5,
  379.                                                     'ipadx': 5,
  380.                                                     'ipady': 5,
  381.                                                     'sticky': 'NSEW',
  382.                                                     'columnconfigure': 1,
  383.                                                     'entry': {
  384.                                                         'type': 'Entry',
  385.                                                         'columnspan': 9900,
  386.                                                         'label': 'Entry Label 3',
  387.                                                         'label_width': 12,
  388.                                                         'label_anchor': 'e',
  389.                                                         'value': 'My Entry Text'
  390.                                                     },
  391.                                                     'spinbox': {
  392.                                                         'row': 2,
  393.                                                         'column': 0,
  394.                                                         'columnspan': 9900,
  395.                                                         'pady': 5,
  396.                                                         'type': 'Spinbox',
  397.                                                         'label': 'Spinbox',
  398.                                                         'label_width': 12,
  399.                                                         'label_anchor': 'e',
  400.                                                         'to': 10,
  401.                                                         'from_': 0,
  402.                                                         'value': '7',
  403.                                                         'wrap': True
  404.                                                     },
  405.                                                     'checkbutton': {
  406.                                                         'type': 'Checkbutton',
  407.                                                         'row': 3,
  408.                                                         'label': 'Check Me',
  409.                                                         'label_width': 12,
  410.                                                         'label_anchor': 'e',
  411.                                                         'value': 0,
  412.                                                         'onvalue': 1
  413.                                                     },
  414.                                                     'sep1': {
  415.                                                         'type': 'Separator',
  416.                                                         'row': 3,
  417.                                                         'column': 1,
  418.                                                         'orient': 'vertical',
  419.                                                         'sticky': 'NS'
  420.                                                     },
  421.                                                     'radiobutton': {
  422.                                                         'type': 'Radiobutton',
  423.                                                         'row': 3,
  424.                                                         'column': 2,
  425.                                                         'items': [
  426.                                                             'one',
  427.                                                             'two',
  428.                                                             'three'
  429.                                                         ],
  430.                                                         'value': 0,
  431.                                                         'sticky': 'w'
  432.                                                     }
  433.                                                 }
  434.                                             },
  435.                                             'two': {
  436.                                                 'label': 'Tab2',
  437.                                                 'content': {
  438.                                                     'type': 'LabelFrame',
  439.                                                     'label': 'Group Title',
  440.                                                     'padx': 5,
  441.                                                     'pady': 5,
  442.                                                     'ipadx': 5,
  443.                                                     'ipady': 5,
  444.                                                     'sticky': 'NSEW',
  445.                                                     'entry': {
  446.                                                         'type': 'Entry',
  447.                                                         'columnspan': 9900,
  448.                                                         'label': 'Entry Label 3',
  449.                                                         'label_width': 12,
  450.                                                         'label_anchor': 'e',
  451.                                                         'value': 'My Entry Text'
  452.                                                     },
  453.                                                     'spinbox': {
  454.                                                         'row': 2,
  455.                                                         'column': 0,
  456.                                                         'columnspan': 9900,
  457.                                                         'pady': 5,
  458.                                                         'type': 'Spinbox',
  459.                                                         'label': 'Spinbox',
  460.                                                         'label_width': 12,
  461.                                                         'label_anchor': 'e',
  462.                                                         'to': 10,
  463.                                                         'from_': 0,
  464.                                                         'value': '7',
  465.                                                         'wrap': True
  466.                                                     },
  467.                                                     'checkbutton': {
  468.                                                         'type': 'Checkbutton',
  469.                                                         'row': 3,
  470.                                                         'label': 'Check Me',
  471.                                                         'label_width': 12,
  472.                                                         'label_anchor': 'e',
  473.                                                         'value': 0,
  474.                                                         'onvalue': 1
  475.                                                     },
  476.                                                     'sep1': {
  477.                                                         'type': 'Separator',
  478.                                                         'row': 3,
  479.                                                         'column': 1,
  480.                                                         'orient': 'vertical',
  481.                                                         'sticky': 'NS'
  482.                                                     },
  483.                                                     'radiobutton': {
  484.                                                         'type': 'Radiobutton',
  485.                                                         'row': 3,
  486.                                                         'column': 2,
  487.                                                         'items': [
  488.                                                             'one',
  489.                                                             'two',
  490.                                                             'three'
  491.                                                         ],
  492.                                                         'value': 0,
  493.                                                         'sticky': 'w'
  494.                                                     }
  495.                                                 }
  496.                                             },
  497.                                             'three': {
  498.                                                 'label': 'Tab3',
  499.                                                 'content': {
  500.                                                     'type': 'LabelFrame',
  501.                                                     'label': 'Group Title',
  502.                                                     'padx': 5,
  503.                                                     'pady': 5,
  504.                                                     'ipadx': 5,
  505.                                                     'ipady': 5,
  506.                                                     'sticky': 'NSEW',
  507.                                                     'entry': {
  508.                                                         'type': 'Entry',
  509.                                                         'columnspan': 9900,
  510.                                                         'label': 'Entry Label 3',
  511.                                                         'label_width': 12,
  512.                                                         'label_anchor': 'e',
  513.                                                         'value': 'Some more Text'
  514.                                                     },
  515.                                                     'spinbox': {
  516.                                                         'row': 2,
  517.                                                         'column': 0,
  518.                                                         'columnspan': 9900,
  519.                                                         'pady': 5,
  520.                                                         'type': 'Spinbox',
  521.                                                         'label': 'Spinbox',
  522.                                                         'label_width': 12,
  523.                                                         'label_anchor': 'e',
  524.                                                         'to': 10,
  525.                                                         'from_': 0,
  526.                                                         'value': '8',
  527.                                                         'wrap': True
  528.                                                     },
  529.                                                     'sep1': {
  530.                                                         'type': 'Separator',
  531.                                                         'row': 3,
  532.                                                         'pady': [
  533.                                                             5,
  534.                                                             0
  535.                                                         ],
  536.                                                         'columnspan': 9900,
  537.                                                         'orient': 'horizontal',
  538.                                                         'columnconfigure': 1,
  539.                                                         'sticky': 'EW'
  540.                                                     },
  541.                                                     'checkbutton': {
  542.                                                         'type': 'Checkbutton',
  543.                                                         'row': 4,
  544.                                                         'label': 'Check Me',
  545.                                                         'label_width': 12,
  546.                                                         'label_anchor': 'e',
  547.                                                         'value': 0,
  548.                                                         'onvalue': 1
  549.                                                     },
  550.                                                     'radiobutton': {
  551.                                                         'type': 'Radiobutton',
  552.                                                         'row': 4,
  553.                                                         'column': 2,
  554.                                                         'items': [
  555.                                                             'one',
  556.                                                             'two',
  557.                                                             'three'
  558.                                                         ],
  559.                                                         'value': 0,
  560.                                                         'sticky': 'w'
  561.                                                     }
  562.                                                 }
  563.                                             }
  564.                                         }
  565.                                     }
  566.                                 }
  567.                             }
  568.                         }
  569.                     },
  570.                 },
  571.             }
  572.         },
  573.         'window2': {
  574.             'type': 'Frame',
  575.             'window_title': 'Demo App2',
  576.             'auto_save': True,
  577.             'auto_start': False,
  578.             'scrollbars': False,
  579.             'save_geometry': True,
  580.             'sticky': 'nsew',
  581.             'content': {
  582.                 'type': 'PanedWindow',
  583.                 'orient': 'horizontal',
  584.                 'sashwidth': 2,
  585.                 'background': '#000000',
  586.                 'sticky': 'nsew',
  587.                 'left_pane': {
  588.                     'type': 'Frame',
  589.                     'treeview': {
  590.                         'type': 'Treeview',
  591.                         'rowspan': 9899,
  592.                         'column': 0,
  593.                         'label': 'Pages',
  594.                         'scrollbars': 'vertical',
  595.                         'items': {
  596.                             'demos': {
  597.                                 'label': 'Demos',
  598.                                 'children': {
  599.                                     '3d_demo': {
  600.                                         'label': '3D Demo'
  601.                                     },
  602.                                     'animation_demo': {
  603.                                         'label': 'Animation Demo'
  604.                                     },
  605.                                     'animation_demo_two': {
  606.                                         'label': 'Animation Demo Two'
  607.                                     }
  608.                                 }
  609.                             },
  610.                             'statistics': {
  611.                                 'label': 'Statistics',
  612.                                 'children': {
  613.                                     'season_win_loss': {
  614.                                         'label': 'Season Win\\Loss'
  615.                                     },
  616.                                     'season_game_times': {
  617.                                         'label': 'Season Game Times'
  618.                                     }
  619.                                 }
  620.                             },
  621.                             'templates': {
  622.                                 'label': 'Templates',
  623.                                 'children': {
  624.                                     'template1': {
  625.                                         'label': 'Template 1'
  626.                                     },
  627.                                     'template2': {
  628.                                         'label': 'Template 2'
  629.                                     },
  630.                                     'template3': {
  631.                                         'label': 'Template 3'
  632.                                     }
  633.                                 }
  634.                             },
  635.                             'templates1': {
  636.                                 'label': 'Templates1',
  637.                                 'children': {
  638.                                     'template1a': {
  639.                                         'label': 'Template 1'
  640.                                     }
  641.                                 }
  642.                             },
  643.                             'templates2': {
  644.                                 'label': 'Templates2',
  645.                                 'children': {
  646.                                     'template2a': {
  647.                                         'label': 'Template 2'
  648.                                     }
  649.                                 }
  650.                             },
  651.                             'templates3': {
  652.                                 'label': 'Templates3',
  653.                                 'children': {
  654.                                     'template3a': {
  655.                                         'label': 'Template 4'
  656.                                     }
  657.                                 }
  658.                             },
  659.                             'templates4': {
  660.                                 'label': 'Templates4',
  661.                                 'children': {
  662.                                     'template4a': {
  663.                                         'label': 'Template 4'
  664.                                     }
  665.                                 }
  666.                             },
  667.                             'templates5': {
  668.                                 'label': 'Templates5',
  669.                                 'children': {
  670.                                     'template5a': {
  671.                                         'label': 'Template 5'
  672.                                     }
  673.                                 }
  674.                             },
  675.                             'templates6': {
  676.                                 'label': 'Templates6',
  677.                                 'children': {
  678.                                     'template6a': {
  679.                                         'label': 'Template 6'
  680.                                     }
  681.                                 }
  682.                             },
  683.                             'templates7': {
  684.                                 'label': 'Templates7',
  685.                                 'children': {
  686.                                     'template7a': {
  687.                                         'label': 'Template 7'
  688.                                     }
  689.                                 }
  690.                             },
  691.                             'templates8': {
  692.                                 'label': 'Templates8',
  693.                                 'children': {
  694.                                     'template8a': {
  695.                                         'label': 'Template 8'
  696.                                     }
  697.                                 }
  698.                             }
  699.                         },
  700.                         'sticky': 'NSEW'
  701.                     }
  702.                 },
  703.                 'right_pane': {
  704.                     'type': 'Frame',
  705.                     'rowconfigure': LAST_ROW,
  706.                     'entry1': {
  707.                         'type': 'Entry',
  708.                         'label': ' Label 1 ',
  709.                         'label_anchor': 'w'
  710.                     },
  711.                     'sep1': {
  712.                         'type': 'Separator',
  713.                         'row': 1,
  714.                         'columnspan': LAST_COLUMN,
  715.                         'orient': 'horizontal',
  716.                         'sticky': 'EW'
  717.                     },
  718.                     'entry2': {
  719.                         'type': 'Entry',
  720.                         'row': 2,
  721.                         'label': ' Label 2 ',
  722.                         'label_anchor': 'w'
  723.                     },
  724.                     'load_defaults': {
  725.                         'type': 'Checkbutton',
  726.                         'row': 3,
  727.                         'label': 'Load Defaults',
  728.                         'value': 1,
  729.                         'sticky': 'nw'
  730.                     },
  731.                     'create_process1': {
  732.                         'type': 'Button',
  733.                         'row': 4,
  734.                         'padx': [0, 5],
  735.                         'text': 'Create Process1',
  736.                         'sticky': 'W'
  737.                     },
  738.                     'create_process2': {
  739.                         'type': 'Button',
  740.                         'row': 5,
  741.                         'padx': [0, 5],
  742.                         'text': 'Create Process2',
  743.                         'sticky': 'W'
  744.                     },
  745.                 }
  746.             }
  747.         },
  748.         'window3': {
  749.             'type': 'Frame',
  750.             'window_title': 'Demo App3',
  751.             'auto_save': True,
  752.             'auto_start': False,
  753.             'scrollbars': False,
  754.             'save_geometry': True,
  755.             'sticky': 'nsew',
  756.             'content': {
  757.                 'type': 'PanedWindow',
  758.                 'orient': 'horizontal',
  759.                 'sashwidth': 2,
  760.                 'background': '#000000',
  761.                 'sticky': 'nsew',
  762.                 'left_pane': {
  763.                     'type': 'Frame',
  764.                     'treeview': {
  765.                         'type': 'Treeview',
  766.                         'rowspan': 9899,
  767.                         'column': 0,
  768.                         'label': 'Pages',
  769.                         'scrollbars': 'vertical',
  770.                         'items': {
  771.                             'demos': {
  772.                                 'label': 'Demos',
  773.                                 'children': {
  774.                                     '3d_demo': {
  775.                                         'label': '3D Demo'
  776.                                     },
  777.                                     'animation_demo': {
  778.                                         'label': 'Animation Demo'
  779.                                     },
  780.                                     'animation_demo_two': {
  781.                                         'label': 'Animation Demo Two'
  782.                                     }
  783.                                 }
  784.                             },
  785.                             'statistics': {
  786.                                 'label': 'Statistics',
  787.                                 'children': {
  788.                                     'season_win_loss': {
  789.                                         'label': 'Season Win\\Loss'
  790.                                     },
  791.                                     'season_game_times': {
  792.                                         'label': 'Season Game Times'
  793.                                     }
  794.                                 }
  795.                             },
  796.                             'templates': {
  797.                                 'label': 'Templates',
  798.                                 'children': {
  799.                                     'template1': {
  800.                                         'label': 'Template 1'
  801.                                     },
  802.                                     'template2': {
  803.                                         'label': 'Template 2'
  804.                                     },
  805.                                     'template3': {
  806.                                         'label': 'Template 3'
  807.                                     }
  808.                                 }
  809.                             },
  810.                             'templates1': {
  811.                                 'label': 'Templates1',
  812.                                 'children': {
  813.                                     'template1a': {
  814.                                         'label': 'Template 1'
  815.                                     }
  816.                                 }
  817.                             },
  818.                             'templates2': {
  819.                                 'label': 'Templates2',
  820.                                 'children': {
  821.                                     'template2a': {
  822.                                         'label': 'Template 2'
  823.                                     }
  824.                                 }
  825.                             },
  826.                             'templates3': {
  827.                                 'label': 'Templates3',
  828.                                 'children': {
  829.                                     'template3a': {
  830.                                         'label': 'Template 4'
  831.                                     }
  832.                                 }
  833.                             },
  834.                             'templates4': {
  835.                                 'label': 'Templates4',
  836.                                 'children': {
  837.                                     'template4a': {
  838.                                         'label': 'Template 4'
  839.                                     }
  840.                                 }
  841.                             },
  842.                             'templates5': {
  843.                                 'label': 'Templates5',
  844.                                 'children': {
  845.                                     'template5a': {
  846.                                         'label': 'Template 5'
  847.                                     }
  848.                                 }
  849.                             },
  850.                             'templates6': {
  851.                                 'label': 'Templates6',
  852.                                 'children': {
  853.                                     'template6a': {
  854.                                         'label': 'Template 6'
  855.                                     }
  856.                                 }
  857.                             },
  858.                             'templates7': {
  859.                                 'label': 'Templates7',
  860.                                 'children': {
  861.                                     'template7a': {
  862.                                         'label': 'Template 7'
  863.                                     }
  864.                                 }
  865.                             },
  866.                             'templates8': {
  867.                                 'label': 'Templates8',
  868.                                 'children': {
  869.                                     'template8a': {
  870.                                         'label': 'Template 8'
  871.                                     }
  872.                                 }
  873.                             }
  874.                         },
  875.                         'sticky': 'NSEW'
  876.                     }
  877.                 },
  878.                 'right_pane': {
  879.                     'type': 'Frame',
  880.                     'rowconfigure': 2,
  881.                     'entry1': {
  882.                         'type': 'Entry',
  883.                         'label': ' Label 1 ',
  884.                         'label_anchor': 'w'
  885.                     },
  886.                     'sep1': {
  887.                         'type': 'Separator',
  888.                         'row': 1,
  889.                         'columnspan': LAST_COLUMN,
  890.                         'orient': 'horizontal',
  891.                         'sticky': 'EW'
  892.                     },
  893.                     'entry2': {
  894.                         'type': 'Entry',
  895.                         'row': 2,
  896.                         'label': ' Label 2 ',
  897.                         'label_anchor': 'w'
  898.                     },
  899.                     'load_defaults': {
  900.                         'type': 'Checkbutton',
  901.                         'row': LAST_ROW,
  902.                         'label': 'Load Defaults',
  903.                         'value': 1,
  904.                     },
  905.                 }
  906.             }
  907.         },
  908.         'window4': {
  909.             'type': 'Frame',
  910.             'window_title': 'Demo App4',
  911.             'auto_save': True,
  912.             'auto_start': False,
  913.             'scrollbars': False,
  914.             'save_geometry': True,
  915.             'sticky': 'nsew',
  916.             'content': {
  917.                 'type': 'PanedWindow',
  918.                 'orient': 'horizontal',
  919.                 'sashwidth': 2,
  920.                 'background': '#000000',
  921.                 'sticky': 'nsew',
  922.                 'left_pane': {
  923.                     'type': 'Frame',
  924.                     'treeview': {
  925.                         'type': 'Treeview',
  926.                         'rowspan': 9899,
  927.                         'column': 0,
  928.                         'label': 'Pages',
  929.                         'scrollbars': 'vertical',
  930.                         'items': {
  931.                             'demos': {
  932.                                 'label': 'Demos',
  933.                                 'children': {
  934.                                     '3d_demo': {
  935.                                         'label': '3D Demo'
  936.                                     },
  937.                                     'animation_demo': {
  938.                                         'label': 'Animation Demo'
  939.                                     },
  940.                                     'animation_demo_two': {
  941.                                         'label': 'Animation Demo Two'
  942.                                     }
  943.                                 }
  944.                             },
  945.                             'statistics': {
  946.                                 'label': 'Statistics',
  947.                                 'children': {
  948.                                     'season_win_loss': {
  949.                                         'label': 'Season Win\\Loss'
  950.                                     },
  951.                                     'season_game_times': {
  952.                                         'label': 'Season Game Times'
  953.                                     }
  954.                                 }
  955.                             },
  956.                             'templates': {
  957.                                 'label': 'Templates',
  958.                                 'children': {
  959.                                     'template1': {
  960.                                         'label': 'Template 1'
  961.                                     },
  962.                                     'template2': {
  963.                                         'label': 'Template 2'
  964.                                     },
  965.                                     'template3': {
  966.                                         'label': 'Template 3'
  967.                                     }
  968.                                 }
  969.                             },
  970.                             'templates1': {
  971.                                 'label': 'Templates1',
  972.                                 'children': {
  973.                                     'template1a': {
  974.                                         'label': 'Template 1'
  975.                                     }
  976.                                 }
  977.                             },
  978.                             'templates2': {
  979.                                 'label': 'Templates2',
  980.                                 'children': {
  981.                                     'template2a': {
  982.                                         'label': 'Template 2'
  983.                                     }
  984.                                 }
  985.                             },
  986.                             'templates3': {
  987.                                 'label': 'Templates3',
  988.                                 'children': {
  989.                                     'template3a': {
  990.                                         'label': 'Template 4'
  991.                                     }
  992.                                 }
  993.                             },
  994.                             'templates4': {
  995.                                 'label': 'Templates4',
  996.                                 'children': {
  997.                                     'template4a': {
  998.                                         'label': 'Template 4'
  999.                                     }
  1000.                                 }
  1001.                             },
  1002.                             'templates5': {
  1003.                                 'label': 'Templates5',
  1004.                                 'children': {
  1005.                                     'template5a': {
  1006.                                         'label': 'Template 5'
  1007.                                     }
  1008.                                 }
  1009.                             },
  1010.                             'templates6': {
  1011.                                 'label': 'Templates6',
  1012.                                 'children': {
  1013.                                     'template6a': {
  1014.                                         'label': 'Template 6'
  1015.                                     }
  1016.                                 }
  1017.                             },
  1018.                             'templates7': {
  1019.                                 'label': 'Templates7',
  1020.                                 'children': {
  1021.                                     'template7a': {
  1022.                                         'label': 'Template 7'
  1023.                                     }
  1024.                                 }
  1025.                             },
  1026.                             'templates8': {
  1027.                                 'label': 'Templates8',
  1028.                                 'children': {
  1029.                                     'template8a': {
  1030.                                         'label': 'Template 8'
  1031.                                     }
  1032.                                 }
  1033.                             }
  1034.                         },
  1035.                         'sticky': 'NSEW'
  1036.                     }
  1037.                 },
  1038.                 'right_pane': {
  1039.                     'type': 'Frame',
  1040.                     'rowconfigure': 2,
  1041.                     'entry1': {
  1042.                         'type': 'Entry',
  1043.                         'label': ' Label 1 ',
  1044.                         'label_anchor': 'w'
  1045.                     },
  1046.                     'sep1': {
  1047.                         'type': 'Separator',
  1048.                         'row': 1,
  1049.                         'columnspan': LAST_COLUMN,
  1050.                         'orient': 'horizontal',
  1051.                         'sticky': 'EW'
  1052.                     },
  1053.                     'entry2': {
  1054.                         'type': 'Entry',
  1055.                         'row': 2,
  1056.                         'label': ' Label 2 ',
  1057.                         'label_anchor': 'w'
  1058.                     },
  1059.                     'load_defaults': {
  1060.                         'type': 'Checkbutton',
  1061.                         'row': LAST_ROW,
  1062.                         'label': 'Load Defaults',
  1063.                         'value': 1,
  1064.                     },
  1065.                 }
  1066.             }
  1067.         }
  1068.     }
  1069.  
  1070.     app = App(
  1071.         title='Demo Application',
  1072.         admin_open=True,
  1073.         admin_close=False,
  1074.         defaults=defaults,
  1075.     )
  1076.  
  1077.     def progress_bar1(window):
  1078.         win = app.get_window(window.id)
  1079.         pb = win.get('content/middle_pane/progress/bar').progressbar
  1080.  
  1081.         def animate():
  1082.             pb.count += 500
  1083.             pb['value'] = pb.count
  1084.             if pb.count < pb['maximum']:
  1085.                 pb.after(pb.refresh_rate, animate)
  1086.             else:
  1087.                 messagebox.showinfo('Info', 'Process Completed Successfully')
  1088.  
  1089.         win.get('content/middle_pane/progress/start').button.config(command=animate)
  1090.  
  1091.     def progress_bar2(window):
  1092.         win = app.get_window(window.id)
  1093.         pb = win.get('content/middle_pane/notebook').tab('one').get('progress/bar').progressbar
  1094.         scale = win.get('content/middle_pane/notebook').tab('one').get('scale').scale
  1095.  
  1096.         def animate(count=None):
  1097.             if count:
  1098.                 pb.count = 0
  1099.  
  1100.             pb.count += 500
  1101.             pb['value'] = pb.count
  1102.             if pb.count < pb['maximum']:
  1103.                 pb.after(int(scale.get()), animate)
  1104.             else:
  1105.                 messagebox.showinfo('Info', 'Process Completed Successfully')
  1106.  
  1107.         win.get('content/middle_pane/notebook').tab('one').get('progress/start').button.config(command=lambda: animate(1))
  1108.  
  1109.     def create_process1(window):
  1110.         win = app.get_window(window.id)
  1111.  
  1112.         def message():
  1113.             messagebox.showinfo('Info', 'This is process 1 ' + window.id)
  1114.  
  1115.         win.get('content/right_pane/create_process1').button.config(command=message)
  1116.  
  1117.     def create_process2(window):
  1118.         win = app.get_window(window.id)
  1119.  
  1120.         def message():
  1121.             messagebox.showinfo('Info', 'This is process 2 ' + window.id)
  1122.  
  1123.         win.get('content/right_pane/create_process2').button.config(command=message)
  1124.  
  1125.     def update_scale(window, val=None):
  1126.         tab = window.get('content/middle_pane/notebook').tab('one')
  1127.         label = tab.get('lscale')
  1128.         scale = tab.get('scale').scale
  1129.  
  1130.         if val is not None:
  1131.             label.var.set(int(float(val)))
  1132.         else:
  1133.             label.var.set(int(scale.get()))
  1134.  
  1135.     def refresh_scale(window):
  1136.         def scale(value):
  1137.             update_scale(window, value)
  1138.  
  1139.         window.get('content/middle_pane/notebook').tab('one').get('scale').scale.config(command=scale)
  1140.  
  1141.     def before_init_cache(admin):
  1142.         messagebox.showinfo('Info', 'before_init_cache hook. ')
  1143.  
  1144.     def after_init_cache(admin):
  1145.         messagebox.showinfo('Info', 'after_init_cache hook. ')
  1146.  
  1147.     def before_init_windows(admin):
  1148.         messagebox.showinfo('Info', 'before_init_windows hook. ')
  1149.  
  1150.     def after_init_windows(admin):
  1151.         messagebox.showinfo('Info', 'after_init_windows hook. ')
  1152.  
  1153.     def before_exit_app(admin):
  1154.         messagebox.showinfo('Info', 'before_exit_app hook. ')
  1155.  
  1156.     def after_exit_app(admin):
  1157.         messagebox.showinfo('Info', 'after_exit_app hook. ')
  1158.  
  1159.     def before_remove_callback(admin):
  1160.         messagebox.showinfo('Info', 'before_remove_callback hook. ')
  1161.  
  1162.     def after_remove_callback(admin):
  1163.         messagebox.showinfo('Info', 'after_remove_callback hook. ')
  1164.  
  1165.     def before_add_callback(admin):
  1166.         messagebox.showinfo('Info', 'before_add_callback hook. ')
  1167.  
  1168.     def after_add_callback(admin):
  1169.         messagebox.showinfo('Info', 'after_add_callback hook. ')
  1170.  
  1171.     def after_admin(obj):
  1172.         messagebox.showinfo('Info', 'This is after_admin ')
  1173.  
  1174.     def before_admin(obj):
  1175.         messagebox.showinfo('Info', 'This is before_admin ')
  1176.  
  1177.     def setup_process1(window):
  1178.         messagebox.showinfo('Info', 'after_open hook. ' + window.id)
  1179.  
  1180.     def setup_process2(window):
  1181.         messagebox.showinfo('Info', 'before_open hook. ' + window.id)
  1182.  
  1183.     def destroy_process1(window):
  1184.         messagebox.showinfo('Info', 'before_close hook. ' + window.id)
  1185.  
  1186.     def destroy_process2():
  1187.         messagebox.showinfo('Info', 'after_close hook. ')
  1188.  
  1189.     # #######################################################################
  1190.     app.add_callback('admin', 'after_admin', after_admin)
  1191.     app.add_callback('admin', 'before_admin', before_admin)
  1192.     app.add_callback('admin', 'after_init_cache', after_init_cache)
  1193.     app.add_callback('admin', 'before_init_cache', before_init_cache)
  1194.     app.add_callback('admin', 'after_init_windows', after_init_windows)
  1195.     app.add_callback('admin', 'before_init_windows', before_init_windows)
  1196.     app.add_callback('admin', 'after_exit_app', after_exit_app)
  1197.     app.add_callback('admin', 'before_exit_app', before_exit_app)
  1198.     app.add_callback('admin', 'after_remove_callback', after_remove_callback)
  1199.     app.add_callback('admin', 'before_remove_callback', before_remove_callback)
  1200.     app.add_callback('admin', 'after_add_callback', after_add_callback)
  1201.     app.add_callback('admin', 'before_add_callback', before_add_callback)
  1202.     # #######################################################################
  1203.     app.add_callback('window1', 'after_open', progress_bar1)
  1204.     app.add_callback('window1', 'after_open', progress_bar2)
  1205.     app.add_callback('window1', 'after_open', update_scale)
  1206.     app.add_callback('window1', 'after_open', refresh_scale)
  1207.     app.add_callback('window1', 'before_open', setup_process2)
  1208.     # #######################################################################
  1209.     app.add_callback('window2', 'after_open', create_process1)
  1210.     app.add_callback('window2', 'after_open', create_process2)
  1211.  
  1212.     app.remove_callback('window2', 'after_open', create_process1)
  1213.  
  1214.     app.add_callback('window2', 'after_open', setup_process1)
  1215.     app.add_callback('window2', 'before_open', setup_process2)
  1216.     app.add_callback('window2', 'before_close', destroy_process1)
  1217.     app.add_callback('window2', 'after_close', destroy_process2)
  1218.     # #######################################################################
  1219.  
  1220.     app.mainloop()
  1221.  
  1222.  
  1223. if __name__ == '__main__':
  1224.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement