Exemple #1
0
    def build_options_list(self):
        """
        Construit la liste des options disponibles

        :return: list(IntVar) - Liste contenant les identifiants des options
        """
        # Label
        opt_label = Label(self, text="Options")
        opt_label.configure(font=font.Font(family=Config.FONT["main"],
                                           size=Config.SIZE["large"]),
                            background=Config.COLOR["main-bg"],
                            foreground=Config.COLOR["main-fg"])
        opt_label.grid(sticky='w', padx=10)

        # Checkbox
        opt_list = []

        for text in Menu.OPTIONS:
            x = IntVar()
            ckb = Checkbutton(self, text=text, variable=x, tristatevalue=0)
            ckb.configure(font=font.Font(family=Config.FONT["main"],
                                         size=Config.SIZE["medium"]),
                          background=Config.COLOR["main-bg"],
                          foreground=Config.COLOR["main-fg"],
                          activebackground=Config.COLOR["main-bg"],
                          activeforeground=Config.COLOR["main-fg"],
                          selectcolor=Config.COLOR["main-bg"])
            ckb.grid(sticky='w', padx=20)
            opt_list.append(x)

        return opt_list
 def _set_checkbox_from_status(control: tk.Checkbutton,
                               control_variable: tk.IntVar, status: int):
     if status == -1:
         control_variable.set(0)
         control.configure(state='disabled')
     else:
         control.configure(state='normal')
         control_variable.set(status)
class SettingsFrame(Frame):
    '''
    Frame inheritance class for application settings and controls.
    '''

    def __init__(self, app, *args, **kwargs):
        '''
        Constructor.
        '''

        self.__app = app  # Reference to main application class
        self.__master = self.__app.get_master()  # Reference to root class (Tk)
        Frame.__init__(self, self.__master, *args, **kwargs)

        self._show_advanced = False
        self._settings = {}
        self._ports = ()
        self._port = StringVar()
        self._port_desc = StringVar()
        self._baudrate = IntVar()
        self._databits = IntVar()
        self._stopbits = DoubleVar()
        self._parity = StringVar()
        self._rtscts = IntVar()
        self._xonxoff = IntVar()
        self._protocol = IntVar()
        self._raw = IntVar()
        self._autoscroll = IntVar()
        self._maxlines = IntVar()
        self._webmap = IntVar()
        self._mapzoom = IntVar()
        self._units = StringVar()
        self._format = StringVar()
        self._datalog = IntVar()
        self._record_track = IntVar()
        self._noports = True
        self._validsettings = True
        self._logpath = None
        self._trackpath = None
        self._img_conn = ImageTk.PhotoImage(Image.open(ICON_CONN))
        self._img_disconn = ImageTk.PhotoImage(Image.open(ICON_DISCONN))
        self._img_ubxconfig = ImageTk.PhotoImage(Image.open(ICON_UBXCONFIG))
        self._img_dataread = ImageTk.PhotoImage(Image.open(ICON_LOGREAD))

        self._body()
        self._do_layout()
        self._get_ports()
        self._reset()

    def _body(self):
        '''
        Set up frame and widgets.
        '''

        for i in range(4):
            self.grid_columnconfigure(i, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.option_add("*Font", self.__app.font_sm)

        # Serial port settings
        self._frm_basic = Frame(self)
        self._lbl_port = Label(self._frm_basic, text="Port")
        self._lbx_port = Listbox(self._frm_basic, border=2,
                                 relief="sunken", bg=ENTCOL,
                                 width=28, height=5, justify=LEFT,
                                 exportselection=False)
        self._scr_portv = Scrollbar(self._frm_basic, orient=VERTICAL)
        self._scr_porth = Scrollbar(self._frm_basic, orient=HORIZONTAL)
        self._lbx_port.config(yscrollcommand=self._scr_portv.set)
        self._lbx_port.config(xscrollcommand=self._scr_porth.set)
        self._scr_portv.config(command=self._lbx_port.yview)
        self._scr_porth.config(command=self._lbx_port.xview)
        self._lbx_port.bind("<<ListboxSelect>>", self._on_select_port)
        self._lbl_baudrate = Label(self._frm_basic, text="Baud rate")
        self._spn_baudrate = Spinbox(self._frm_basic,
                                     values=(BAUDRATES),
                                     width=8, state=READONLY, readonlybackground=ENTCOL,
                                     wrap=True, textvariable=self._baudrate)
        self._btn_toggle = Button(self._frm_basic, text=ADVOFF, width=3,
                                  command=self._toggle_advanced)

        self._frm_advanced = Frame(self)
        self._lbl_databits = Label(self._frm_advanced, text="Data Bits")
        self._spn_databits = Spinbox(self._frm_advanced, values=(8, 7, 6, 5),
                                     width=3, state=READONLY, readonlybackground=ENTCOL,
                                     wrap=True, textvariable=self._databits)
        self._lbl_stopbits = Label(self._frm_advanced, text="Stop Bits")
        self._spn_stopbits = Spinbox(self._frm_advanced, values=(2, 1.5, 1),
                                     width=3, state=READONLY, readonlybackground=ENTCOL,
                                     wrap=True, textvariable=self._stopbits)
        self._lbl_parity = Label(self._frm_advanced, text="Parity")
        self._spn_parity = Spinbox(self._frm_advanced,
                                   values=("None", "Even", "Odd", "Mark", "Space"),
                                   width=6, state=READONLY, readonlybackground=ENTCOL,
                                   wrap=True, textvariable=self._parity)
        self._chk_rts = Checkbutton(self._frm_advanced, text="RTS/CTS",
                                    variable=self._rtscts)
        self._chk_xon = Checkbutton(self._frm_advanced, text="Xon/Xoff",
                                    variable=self._xonxoff)

        self._frm_buttons = Frame(self)
        self._btn_connect = Button(self._frm_buttons, width=45, height=35,
                                  image=self._img_conn,
                                  command=lambda: self.__app.serial_handler.connect())
        self._btn_disconnect = Button(self._frm_buttons, width=45, height=35,
                                     image=self._img_disconn,
                                     command=lambda: self.__app.serial_handler.disconnect(),
                                     state=DISABLED)
        self._btn_connect_file = Button(self._frm_buttons, width=45, height=35,
                                     image=self._img_dataread,
                                     command=lambda: self._on_data_stream())
        self._lbl_status_preset = Label(self._frm_buttons, font=self.__app.font_md2, text='')

        # Other configuration options
        self._frm_options = Frame(self)
        self._lbl_protocol = Label(self._frm_options, text=LBLPROTDISP)
        self._rad_nmea = Radiobutton(self._frm_options, text="NMEA",
                                    variable=self._protocol, value=NMEA_PROTOCOL)
        self._rad_ubx = Radiobutton(self._frm_options, text="UBX",
                                    variable=self._protocol, value=UBX_PROTOCOL)
        self._rad_all = Radiobutton(self._frm_options, text="ALL",
                                    variable=self._protocol, value=MIXED_PROTOCOL)
        self._lbl_consoledisplay = Label(self._frm_options, text=LBLDATADISP)
        self._rad_parsed = Radiobutton(self._frm_options, text="Parsed",
                                    variable=self._raw, value=0)
        self._rad_raw = Radiobutton(self._frm_options, text="Raw",
                                   variable=self._raw, value=1)
        self._lbl_format = Label(self._frm_options, text="Degrees Format")
        self._spn_format = Spinbox(self._frm_options,
                                  values=(DDD, DMS, DMM),
                                  width=6, state=READONLY, readonlybackground=ENTCOL,
                                  wrap=True, textvariable=self._format)
        self._lbl_units = Label(self._frm_options, text="Units")
        self._spn_units = Spinbox(self._frm_options,
                                  values=(UMM, UIK, UI, UMK),
                                  width=13, state=READONLY, readonlybackground=ENTCOL,
                                  wrap=True, textvariable=self._units)
        self._chk_scroll = Checkbutton(self._frm_options, text="Autoscroll",
                                      variable=self._autoscroll)
        self._spn_maxlines = Spinbox(self._frm_options,
                                     values=("100", "200", "500", "1000", "2000"),
                                    width=6, readonlybackground=ENTCOL, wrap=True,
                                    textvariable=self._maxlines, state=READONLY)
        self._chk_webmap = Checkbutton(self._frm_options, text="Web Map  Zoom",
                                      variable=self._webmap)
        self._scl_mapzoom = Scale(self._frm_options, from_=1, to=20, orient=HORIZONTAL,
                                  relief="sunken", bg=ENTCOL, variable=self._mapzoom)
        self._chk_datalog = Checkbutton(self._frm_options, text=LBLDATALOG,
                                        variable=self._datalog,
                                        command=lambda: self._on_data_log())

        self._chk_recordtrack = Checkbutton(self._frm_options, text=LBLTRACKRECORD,
                                        variable=self._record_track,
                                        command=lambda: self._on_record_track())

        self._lbl_ubxconfig = Label(self._frm_options, text=LBLUBXCONFIG)
        self._btn_ubxconfig = Button(self._frm_options, width=45, height=35,
                                     text='UBX', image=self._img_ubxconfig,
                                     command=lambda: self._on_ubx_config(),
                                     state=DISABLED)

    def _do_layout(self):
        '''
        Position widgets in frame.
        '''

        self._frm_basic.grid(column=0, row=0, columnspan=4, sticky=(W, E))
        self._lbl_port.grid(column=0, row=0, sticky=(W))
        self._lbx_port.grid(column=1, row=0, sticky=(W, E), padx=3, pady=3)
        self._scr_portv.grid(column=2, row=0, sticky=(N, S))
        self._scr_porth.grid(column=1, row=1, sticky=(E, W))
        self._lbl_baudrate.grid(column=0, row=2, sticky=(W))
        self._spn_baudrate.grid(column=1, row=2, sticky=(W), padx=3, pady=3)
        self._btn_toggle.grid(column=2, row=2, sticky=(E))

        self._frm_advanced.grid_forget()
        self._lbl_databits.grid(column=0, row=0, sticky=(W))
        self._spn_databits.grid(column=1, row=0, sticky=(W), padx=3, pady=3)
        self._lbl_stopbits.grid(column=2, row=0, sticky=(W))
        self._spn_stopbits.grid(column=3, row=0, sticky=(W), padx=3, pady=3)
        self._lbl_parity.grid(column=0, row=1, sticky=(W))
        self._spn_parity.grid(column=1, row=1, sticky=(W), padx=3, pady=3)
        self._chk_rts.grid(column=2, row=1, sticky=(W))
        self._chk_xon.grid(column=3, row=1, sticky=(W), padx=3, pady=3)

        ttk.Separator(self).grid(column=0, row=2, columnspan=4,
                                            padx=3, pady=3, sticky=(W, E))

        self._frm_buttons.grid(column=0, row=3, columnspan=4, sticky=(W, E))
        self._btn_connect.grid(column=0, row=0, padx=3, pady=3)
        self._btn_connect_file.grid(column=1, row=0, padx=3, pady=3)
        self._btn_disconnect.grid(column=3, row=0, padx=3, pady=3)

        ttk.Separator(self).grid(column=0, row=7, columnspan=4,
                                            padx=3, pady=3, sticky=(W, E))

        self._frm_options.grid(column=0, row=8, columnspan=4, sticky=(W, E))
        self._lbl_protocol.grid(column=0, row=0, padx=3, pady=3, sticky=(W))
        self._rad_nmea.grid(column=1, row=0, padx=0, pady=0, sticky=(W))
        self._rad_ubx.grid(column=2, row=0, padx=0, pady=0, sticky=(W))
        self._rad_all.grid(column=3, row=0, padx=0, pady=0, sticky=(W))
        self._lbl_consoledisplay.grid(column=0, row=1, padx=2, pady=3, sticky=(W))
        self._rad_parsed.grid(column=1, row=1, padx=1, pady=3, sticky=(W))
        self._rad_raw.grid(column=2, row=1, padx=2, pady=3, sticky=(W))
        self._lbl_format.grid(column=0, row=2, padx=3, pady=3, sticky=(W))
        self._spn_format.grid(column=1, row=2, padx=2, pady=3, sticky=(W))
        self._lbl_units.grid(column=0, row=3, padx=3, pady=3, sticky=(W))
        self._spn_units.grid(column=1, row=3, columnspan=3, padx=2, pady=3, sticky=(W))
        self._chk_scroll.grid(column=0, row=4, padx=3, pady=3, sticky=(W))
        self._spn_maxlines.grid(column=1, row=4, columnspan=3, padx=3, pady=3, sticky=(W))
        self._chk_webmap.grid(column=0, row=5, sticky=(W))
        self._scl_mapzoom.grid(column=1, row=5, columnspan=3, sticky=(W))
        self._chk_datalog.grid(column=0, row=6, padx=3, pady=3, sticky=(W))
        self._chk_recordtrack.grid(column=0, row=7, padx=3, pady=3, sticky=(W))

        ttk.Separator(self._frm_options).grid(column=0, row=8, columnspan=4,
                                 padx=3, pady=3, sticky=(W, E))
        self._lbl_ubxconfig.grid(column=0, row=9, padx=3, pady=3, sticky=(W))
        self._btn_ubxconfig.grid(column=1, row=9, padx=3, pady=3, sticky=(W))

    def _on_select_port(self, *args, **kwargs):
        '''
        Get selected port from listbox and set global variable.
        '''

        idx = self._lbx_port.curselection()
        if  idx == "":
            idx = 0
        port_orig = self._lbx_port.get(idx)
        port = port_orig[0:port_orig.find(":")]
        desc = port_orig[port_orig.find(":") + 1:]
        if desc == '':
            desc = "device"
        self._port.set(port)
        self._port_desc.set(desc)

    def _on_ubx_config(self, *args, **kwargs):
        '''
        Open UBX configuration dialog panel.
        '''

        self.__app.ubxconfig()

    def _on_data_log(self):
        '''
        Start or stop data logger
        '''

        if self._datalog.get() == 1:
            self._logpath = self.__app.file_handler.set_logfile_path()
            if self._logpath is not None:
                self.__app.set_status("Data logging enabled: " + self._logpath, "green")
            else:
                self._datalog.set(False)
        else:
            self._logpath = None
            self._datalog.set(False)
#             self.__app.file_handler.close_logfile()
            self.__app.set_status("Data logging disabled", "blue")

    def _on_record_track(self):
        '''
        Start or stop track recorder
        '''

        if self._record_track.get() == 1:
            self._trackpath = self.__app.file_handler.set_trackfile_path()
            if self._trackpath is not None:
                self.__app.set_status("Track recording enabled: " + self._trackpath, "green")
            else:
                self._record_track.set(False)
        else:
            self._trackpath = None
            self._record_track.set(False)
#             self.__app.file_handler.close_trackfile()
            self.__app.set_status("Track recording disabled", "blue")

    def _on_data_stream(self):
        '''
        Start data file streamer
        '''

        self._logpath = self.__app.file_handler.open_logfile_input()
        if self._logpath is not None:
            self.__app.set_status("")
            self.__app.serial_handler.connect_file()

    def _toggle_advanced(self):
        '''
        Toggle advanced serial port settings panel on or off
        '''

        self._show_advanced = not self._show_advanced
        if self._show_advanced:
            self._frm_advanced.grid(column=0, row=1, columnspan=3, sticky=(W, E))
            self._btn_toggle.config(text=ADVON)
        else:
            self._frm_advanced.grid_forget()
            self._btn_toggle.config(text=ADVOFF)

    def _get_ports(self):
        '''
        Populate list of available serial ports using pyserial comports tool.
        If no ports found, disable all connection-dependent widgets.

        Attempt to preselect the first port that has a recognisable
        GPS designation in its description (usually only works on
        Posix platforms - Windows doesn't parse UART device desc or HWID)
        '''

        self._ports = sorted(comports())
        init_idx = 0
        port = ''
        desc = ''
        if len(self._ports) > 0:
            for idx, (port, desc, _) in enumerate(self._ports, 1):
                self._lbx_port.insert(idx, port + ": " + desc)
                for kgp in KNOWNGPS:
                    if kgp in desc:
                        init_idx = idx
                        break
            self._noports = False
        else:
            self._noports = True
            self.set_controls(NOPORTS)
        self._lbx_port.activate(init_idx)
        self._port.set(port)
        self._port_desc.set(desc)

    def _reset(self):
        '''
        Reset settings to defaults.
        '''

        self._baudrate.set(BAUDRATES[4])  # 9600
        self._databits.set(8)
        self._stopbits.set(1)
        self._parity.set("None")
        self._rtscts.set(False)
        self._xonxoff.set(False)
        self._protocol.set(MIXED_PROTOCOL)
        self._format.set(DDD)
        self._units.set(UMM)
        self._autoscroll.set(1)
        self._maxlines.set(300)
        self._raw.set(False)
        self._webmap.set(False)
        self._mapzoom.set(10)
        self._datalog.set(False)
        self._record_track.set(False)

    def set_controls(self, status):
        '''
        ...for the heart of the sun.
        Public method to enable and disable serial port controls
        depending on connection status.
        '''

        self._lbl_port.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._lbx_port.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._lbl_baudrate.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._spn_baudrate.configure(state=(READONLY if status == DISCONNECTED else DISABLED))
        self._lbl_databits.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._spn_databits.configure(state=(READONLY if status == DISCONNECTED else DISABLED))
        self._lbl_stopbits.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._spn_stopbits.configure(state=(READONLY if status == DISCONNECTED else DISABLED))
        self._lbl_parity.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._spn_parity.configure(state=(READONLY if status == DISCONNECTED else DISABLED))
        self._chk_rts.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._chk_xon.configure(state=(NORMAL if status == DISCONNECTED else DISABLED))
        self._btn_connect.config(state=(DISABLED if status in \
                                        (CONNECTED, CONNECTED_FILE, NOPORTS) \
                                        else NORMAL))
        self._btn_disconnect.config(state=(DISABLED if status in \
                                           (DISCONNECTED, NOPORTS) else NORMAL))
        self._chk_datalog.config(state=(DISABLED if status in \
                                        (CONNECTED, CONNECTED_FILE, NOPORTS) \
                                        else NORMAL))
        self._chk_recordtrack.config(state=(DISABLED if status in \
                                        (CONNECTED, CONNECTED_FILE) \
                                        else NORMAL))
        self._btn_connect_file.config(state=(DISABLED if status in \
                                             (CONNECTED, CONNECTED_FILE) \
                                             else NORMAL))
        self._btn_ubxconfig.config(state=(DISABLED if status in \
                                          (DISCONNECTED, CONNECTED_FILE, NOPORTS) \
                                          else NORMAL))
        self.__app.menu.options_menu.entryconfig(0, state=(DISABLED if status in \
                                          (CONNECTED_FILE, DISCONNECTED, NOPORTS) \
                                          else NORMAL))

    def get_settings(self):
        '''
        Public method returns all settings as a dict.
        '''

        self._settings['port'] = self._port.get()
        self._settings['noports'] = self._noports
        self._settings['port_desc'] = self._port_desc.get()
        self._settings['baudrate'] = self._baudrate.get()
        self._settings['databits'] = self._databits.get()
        self._settings['stopbits'] = self._stopbits.get()
        self._settings['parity'] = self._parity.get()
        self._settings['rtscts'] = self._rtscts.get()
        self._settings['xonxoff'] = self._xonxoff.get()
        self._settings['protocol'] = self._protocol.get()
        self._settings['raw'] = self._raw.get()
        self._settings['autoscroll'] = self._autoscroll.get()
        self._settings['maxlines'] = self._maxlines.get()
        self._settings['webmap'] = self._webmap.get()
        self._settings['mapzoom'] = self._mapzoom.get()
        self._settings['units'] = self._units.get()
        self._settings['format'] = self._format.get()
        self._settings['logpath'] = self._logpath
        self._settings['datalogging'] = self._datalog.get()
        self._settings['recordtrack'] = self._record_track.get()

        return self._settings

    def get_size(self):
        '''
        Get current frame size.
        '''

        self.update_idletasks()  # Make sure we know about any resizing
        return (self.winfo_width(), self.winfo_height())
class _full_combo:
    def __init__(self, master):
    
        grid_frame = Frame( master )
        self.grid_frame = grid_frame
        grid_frame.pack(expand=1, fill=BOTH)
        self.master = master
        
        self.x, self.y, self.w, self.h = 10, 10, 519, 326

        self.master.title("full_combo")

        self.RadioGroup_1_StringVar = StringVar()

        self.make_Button_1( self.grid_frame )          #      Button:  at Main(1,1)
        self.make_Notebook_1( self.grid_frame )        #    Notebook:  at Main(1,2)
        self.make_Tab_1( self.Notebook_1 )             #         Tab: Small : at Notebook_1(1,1)
        self.make_Tab_2( self.Notebook_1 )             #         Tab: Medium : at Notebook_1(1,2)
        self.make_Tab_3( self.Notebook_1 )             #         Tab: Large : at Notebook_1(1,3)
        self.make_Canvas_1( self.Tab_1 )               #      Canvas:  at Tab_1(1,3)
        self.make_Frame_1( self.Tab_1 )                #       Frame:  at Tab_1(1,2)
        self.make_Checkbutton_2( self.Frame_1 )        # Checkbutton:  at Frame_1(1,1)
        self.make_Combobox_2( self.Frame_1 )           #    Combobox: Mine Yours Ours : at Frame_1(2,1)
        self.make_Entry_2( self.Frame_1 )              #       Entry:  at Frame_1(3,1)
        self.make_LabelFrame_1( self.Tab_2 )           #  LabelFrame: Left : at Tab_2(1,1)
        self.make_LabelFrame_2( self.Tab_2 )           #  LabelFrame: Right : at Tab_2(1,2)
        self.make_Listbox_1( self.LabelFrame_1 )       #     Listbox:  at LabelFrame_1(1,1)
        self.make_Message_1( self.LabelFrame_1 )       #     Message:  at LabelFrame_1(2,1)
        self.make_Menubutton_1( self.LabelFrame_2 )    #  Menubutton:  at LabelFrame_2(1,1)
        self.make_Notebook_2( self.LabelFrame_2 )      #    Notebook:  at LabelFrame_2(2,1)
        self.make_Tab_4( self.Notebook_2 )             #         Tab:  at Notebook_2(1,1)
        self.make_Tab_5( self.Notebook_2 )             #         Tab:  at Notebook_2(1,2)
        self.make_RadioGroup_1( self.Tab_4 )           #  RadioGroup:  at Tab_4(1,1)
        self.make_Radiobutton_1( self.RadioGroup_1 )   # Radiobutton: 1 : at RadioGroup_1(2,1)
        self.make_Radiobutton_2( self.RadioGroup_1 )   # Radiobutton: 2 : at RadioGroup_1(3,1)
        self.make_Radiobutton_3( self.RadioGroup_1 )   # Radiobutton: 3 : at RadioGroup_1(4,1)
        self.make_Radiobutton_4( self.RadioGroup_1 )   # Radiobutton: 4 : at RadioGroup_1(5,1)
        self.make_Scale_1( self.Tab_5 )                #       Scale: 2.5 to 7.5 : at Tab_5(2,1)
        self.make_Spinbox_1( self.Tab_5 )              #     Spinbox: 1 to 10 : at Tab_5(3,1)
        self.make_Button_2( self.Tab_3 )               #      Button:  at Tab_3(3,1)
        self.make_Text_1( self.Tab_3 )                 #        Text:  at Tab_3(2,1)
        self.make_Treeview_1( self.Tab_3 )             #    Treeview:  at Tab_3(2,2)

        self.grid_frame.rowconfigure(1, weight=1)
        self.Tab_1.rowconfigure(1, weight=1)
        self.Tab_2.rowconfigure(1, weight=1)
        self.LabelFrame_1.columnconfigure(1, weight=1)
        self.grid_frame.columnconfigure(2, weight=1)
        self.Tab_2.columnconfigure(2, weight=1)
        self.Tab_1.columnconfigure(3, weight=1)
        self.Tab_2.columnconfigure(1, weight=1)

        self.RadioGroup_1_StringVar.set("1")
        self.RadioGroup_1_StringVar_traceName = self.RadioGroup_1_StringVar.trace_variable("w", self.RadioGroup_1_StringVar_Callback)
        # >>>>>>insert any user code below this comment for section "top_of_init"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Button_1"
    def make_Button_1(self, frame):
        """      Button:  at Main(1,1)"""
        self.Button_1 = Button( frame , text="Button_1", width="15", anchor="e")
        self.Button_1.grid(row=1, column=1, sticky="s")

        # >>>>>>insert any user code below this comment for section "make_Button_1"

        self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Notebook_1"
    def make_Notebook_1(self, frame):
        """    Notebook:  at Main(1,2)"""
        self.Notebook_1 = Notebook ( frame , width="400", height="300")
        self.Notebook_1.grid(row=1, column=2, sticky="nsew")

        # >>>>>>insert any user code below this comment for section "make_Notebook_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Tab_1"
    def make_Tab_1(self, frame):
        """         Tab: Small : at Notebook_1(1,1)"""
        self.Tab_1 = Frame( frame )
        self.Notebook_1.add( self.Tab_1, text="Small" )
        # >>>>>>insert any user code below this comment for section "make_Tab_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Tab_2"
    def make_Tab_2(self, frame):
        """         Tab: Medium : at Notebook_1(1,2)"""
        self.Tab_2 = Frame( frame )
        self.Notebook_1.add( self.Tab_2, text="Medium" )
        # >>>>>>insert any user code below this comment for section "make_Tab_2"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Tab_3"
    def make_Tab_3(self, frame):
        """         Tab: Large : at Notebook_1(1,3)"""
        self.Tab_3 = Frame( frame )
        self.Notebook_1.add( self.Tab_3, text="Large" )
        # >>>>>>insert any user code below this comment for section "make_Tab_3"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Canvas_1"
    def make_Canvas_1(self, frame):
        """      Canvas:  at Tab_1(1,3)"""
        self.Canvas_1 = Canvas( frame , height="50", width="60")
        self.Canvas_1.grid(row=1, column=3, sticky="nsew")

        # >>>>>>insert any user code below this comment for section "make_Canvas_1"

        self.Canvas_1.config(bg='#ffffcc')
        self.Canvas_1.bind("<ButtonRelease-1>", self.Canvas_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Frame_1"
    def make_Frame_1(self, frame):
        """       Frame:  at Tab_1(1,2)"""
        self.Frame_1 = Frame( frame , width="60", height="50")
        self.Frame_1.grid(row=1, column=2, sticky="n")

        # >>>>>>insert any user code below this comment for section "make_Frame_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_2"
    def make_Checkbutton_2(self, frame):
        """ Checkbutton:  at Frame_1(1,1)"""
        self.Checkbutton_2 = Checkbutton( frame , text="Checkbutton_2", width="15", anchor="e")
        self.Checkbutton_2.grid(row=1, column=1)
        self.Checkbutton_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_2"

        self.Checkbutton_2.configure(variable=self.Checkbutton_2_StringVar, onvalue="yes", offvalue="no")
        self.Checkbutton_2_StringVar.set("no")
        self.Checkbutton_2_StringVar_traceName = self.Checkbutton_2_StringVar.trace_variable("w", self.Checkbutton_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Combobox_2"
    def make_Combobox_2(self, frame):
        """    Combobox: Mine Yours Ours : at Frame_1(2,1)"""
        self.Combobox_2 = Combobox( frame , text="Combobox_2", values="Mine Yours Ours")
        self.Combobox_2.grid(row=2, column=1)
        self.Combobox_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Combobox_2"

        self.Combobox_2.configure(textvariable=self.Combobox_2_StringVar)
        self.Combobox_2_StringVar.set( "Mine" )
        self.Combobox_2_StringVar_traceName = self.Combobox_2_StringVar.trace_variable("w", self.Combobox_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Entry_2"
    def make_Entry_2(self, frame):
        """       Entry:  at Frame_1(3,1)"""
        self.Entry_2 = Entry( frame , width="15")
        self.Entry_2.grid(row=3, column=1)
        self.Entry_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Entry_2"

        self.Entry_2.configure(textvariable=self.Entry_2_StringVar)
        self.Entry_2_StringVar_traceName = self.Entry_2_StringVar.trace_variable("w", self.Entry_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_LabelFrame_1"
    def make_LabelFrame_1(self, frame):
        """  LabelFrame: Left : at Tab_2(1,1)"""
        self.LabelFrame_1 = LabelFrame( frame , text="Left", width="60", height="50")
        self.LabelFrame_1.grid(row=1, column=1, sticky="nsew")

        # >>>>>>insert any user code below this comment for section "make_LabelFrame_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_LabelFrame_2"
    def make_LabelFrame_2(self, frame):
        """  LabelFrame: Right : at Tab_2(1,2)"""
        self.LabelFrame_2 = LabelFrame( frame , text="Right", width="60", height="50")
        self.LabelFrame_2.grid(row=1, column=2, sticky="nsew")

        # >>>>>>insert any user code below this comment for section "make_LabelFrame_2"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Listbox_1"
    def make_Listbox_1(self, frame):
        """     Listbox:  at LabelFrame_1(1,1)"""
        self.Listbox_1 = Listbox( frame , height="12", width="30")
        self.Listbox_1.grid(row=1, column=1)

        # >>>>>>insert any user code below this comment for section "make_Listbox_1"


        # Edit the Listbox Entries
        self.Listbox_1.insert(END, "apples")
        self.Listbox_1.insert(END, "oranges")
        self.Listbox_1.insert(END, "grapes")

        self.Listbox_1.bind("<ButtonRelease-1>", self.Listbox_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Message_1"
    def make_Message_1(self, frame):
        """     Message:  at LabelFrame_1(2,1)"""
        self.Message_1 = Message( frame , text="Message_1", width="55", anchor="e")
        self.Message_1.grid(row=2, column=1, sticky="ew")

        # >>>>>>insert any user code below this comment for section "make_Message_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Menubutton_1"
    def make_Menubutton_1(self, frame):
        """  Menubutton:  at LabelFrame_2(1,1)"""
        self.Menubutton_1 = Menubutton( frame , text="Menubutton_1", width="15", anchor="e")
        self.Menubutton_1.grid(row=1, column=1)
        self.Menubutton_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Menubutton_1"

        self.Menubutton_1.configure(textvariable=self.Menubutton_1_StringVar, text="Select")
        self.Menubutton_1_StringVar.set("Select")
        self.Menubutton_1_StringVar_traceName = self.Menubutton_1_StringVar.trace_variable("w", self.Menubutton_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Notebook_2"
    def make_Notebook_2(self, frame):
        """    Notebook:  at LabelFrame_2(2,1)"""
        self.Notebook_2 = Notebook ( frame , width="400", height="300")
        self.Notebook_2.grid(row=2, column=1)

        # >>>>>>insert any user code below this comment for section "make_Notebook_2"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Tab_4"
    def make_Tab_4(self, frame):
        """         Tab:  at Notebook_2(1,1)"""
        self.Tab_4 = Frame( frame )
        self.Notebook_2.add( self.Tab_4, text="Tab_4" )
        # >>>>>>insert any user code below this comment for section "make_Tab_4"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Tab_5"
    def make_Tab_5(self, frame):
        """         Tab:  at Notebook_2(1,2)"""
        self.Tab_5 = Frame( frame )
        self.Notebook_2.add( self.Tab_5, text="Tab_5" )
        # >>>>>>insert any user code below this comment for section "make_Tab_5"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_RadioGroup_1"
    def make_RadioGroup_1(self, frame):
        """  RadioGroup:  at Tab_4(1,1)"""
        self.RadioGroup_1 = LabelFrame( frame , width="60", height="50")
        self.RadioGroup_1.grid(row=1, column=1)

        # >>>>>>insert any user code below this comment for section "make_RadioGroup_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_1"
    def make_Radiobutton_1(self, frame):
        """ Radiobutton: 1 : at RadioGroup_1(2,1)"""
        self.Radiobutton_1 = Radiobutton( frame , text="Radiobutton_1", value="1", width="15", anchor="e")
        self.Radiobutton_1.grid(row=2, column=1)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_1"

        self.Radiobutton_1.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_2"
    def make_Radiobutton_2(self, frame):
        """ Radiobutton: 2 : at RadioGroup_1(3,1)"""
        self.Radiobutton_2 = Radiobutton( frame , text="Radiobutton_2", value="2", width="15")
        self.Radiobutton_2.grid(row=3, column=1)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_2"

        self.Radiobutton_2.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_3"
    def make_Radiobutton_3(self, frame):
        """ Radiobutton: 3 : at RadioGroup_1(4,1)"""
        self.Radiobutton_3 = Radiobutton( frame , text="Radiobutton_3", value="3", width="15")
        self.Radiobutton_3.grid(row=4, column=1)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_3"

        self.Radiobutton_3.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_4"
    def make_Radiobutton_4(self, frame):
        """ Radiobutton: 4 : at RadioGroup_1(5,1)"""
        self.Radiobutton_4 = Radiobutton( frame , text="Radiobutton_4", value="4", width="15")
        self.Radiobutton_4.grid(row=5, column=1)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_4"

        self.Radiobutton_4.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Scale_1"
    def make_Scale_1(self, frame):
        """       Scale: 2.5 to 7.5 : at Tab_5(2,1)"""
        self.Scale_1 = Scale( frame , digits="3", tickinterval="1", to="7.5", from_="2.5", resolution=".5")
        self.Scale_1.grid(row=2, column=1)
        self.Scale_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Scale_1"

        self.Scale_1.configure(variable=self.Scale_1_StringVar)
        self.Scale_1_StringVar_traceName = self.Scale_1_StringVar.trace_variable("w", self.Scale_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Spinbox_1"
    def make_Spinbox_1(self, frame):
        """     Spinbox: 1 to 10 : at Tab_5(3,1)"""
        self.Spinbox_1 = Spinbox( frame , to="10", text="Spinbox_1", width="15", from_="1")
        self.Spinbox_1.grid(row=3, column=1)
        self.Spinbox_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Spinbox_1"

        self.Spinbox_1.configure(textvariable=self.Spinbox_1_StringVar, to="10", from_="1")
        self.Spinbox_1_StringVar.set("1")
        self.Spinbox_1_StringVar_traceName = self.Spinbox_1_StringVar.trace_variable("w", self.Spinbox_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Button_2"
    def make_Button_2(self, frame):
        """      Button:  at Tab_3(3,1)"""
        self.Button_2 = Button( frame , text="Button_2", width="15")
        self.Button_2.grid(row=3, column=1)

        # >>>>>>insert any user code below this comment for section "make_Button_2"

        self.Button_2.bind("<ButtonRelease-1>", self.Button_2_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Text_1"
    def make_Text_1(self, frame):
        """        Text:  at Tab_3(2,1)"""

        lbframe = Frame( frame )
        self.Text_1_frame = lbframe
        vbar=Scrollbar(lbframe, orient=VERTICAL)
        self.Text_1 = Text(lbframe, width="40", height="12", yscrollcommand=vbar.set)
        vbar.config(command=self.Text_1.yview)
        
        vbar.grid(row=0, column=1, sticky='ns')        
        self.Text_1.grid(row=0, column=0)

        self.Text_1_frame.grid(row=2, column=1)

        # >>>>>>insert any user code below this comment for section "make_Text_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Treeview_1"
    def make_Treeview_1(self, frame):
        """    Treeview:  at Tab_3(2,2)"""
        self.Treeview_1 = Treeview( frame )
        self.Treeview_1.grid(row=2, column=2)

        # >>>>>>insert any user code below this comment for section "make_Treeview_1"


        self.Treeview_1.insert('', 'end', 'widgets', text='Widget Tour')
        # Same thing, but inserted as first child:
        self.Treeview_1.insert('', 0, 'gallery', text='Treeview_1')
        # Inserted underneath an existing node:
        self.Treeview_1.insert('widgets', 'end', text='Button')
        self.Treeview_1.insert('widgets', 'end', text='Canvas')
        self.Treeview_1.insert('widgets', 'end', text='Checkbutton')
        self.Treeview_1.insert('widgets', 'end', text='Combobox')
        self.Treeview_1.insert('widgets', 'end', text='Entry')
        self.Treeview_1.insert('widgets', 'end', text='Frame')
        self.Treeview_1.insert('widgets', 'end', text='Label')
        self.Treeview_1.insert('widgets', 'end', text='LabelFrame')
        self.Treeview_1.insert('widgets', 'end', text='Listbox')
        self.Treeview_1.insert('widgets', 'end', text='Menubutton')
        self.Treeview_1.insert('widgets', 'end', text='Message')
        self.Treeview_1.insert('widgets', 'end', text='Notebook')
        self.Treeview_1.insert('widgets', 'end', text='OptionMenu')
        self.Treeview_1.insert('widgets', 'end', text='Progressbar')
        self.Treeview_1.insert('widgets', 'end', text='RadioGroup')
        self.Treeview_1.insert('widgets', 'end', text='Radiobutton')
        self.Treeview_1.insert('widgets', 'end', text='Scale')
        self.Treeview_1.insert('widgets', 'end', text='Separator')
        self.Treeview_1.insert('widgets', 'end', text='Spinbox')
        self.Treeview_1.insert('widgets', 'end', text='Tab')
        self.Treeview_1.insert('widgets', 'end', text='Text')
        self.Treeview_1.insert('widgets', 'end', text='Treeview')

        # Treeview chooses the id:
        id = self.Treeview_1.insert('', 'end', text='Tutorial')
        self.Treeview_1.insert(id, 'end', text='Tree')

        self.Treeview_1.bind("<ButtonRelease-1>", self.Treeview_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Button_1_Click"
    def Button_1_Click(self, event): #bind method for component ID=Button_1
        """      Button:  at Main(1,1)"""
        pass
        # >>>>>>insert any user code below this comment for section "Button_1_Click"
        # replace, delete, or comment-out the following
        print( "executed method Button_1_Click" )

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Canvas_1_Click"
    def Canvas_1_Click(self, event): #bind method for component ID=Canvas_1
        """      Canvas:  at Tab_1(1,3)"""
        pass
        # >>>>>>insert any user code below this comment for section "Canvas_1_Click"
        # replace, delete, or comment-out the following
        print( "executed method Canvas_1_Click" )

        print( "clicked in canvas at x,y =",event.x,event.y )
        w = int(self.Canvas_1.cget("width"))
        h = int(self.Canvas_1.cget("height"))
        self.Canvas_1.create_rectangle((2, 2, w+1, h+1), outline="blue")
        self.Canvas_1.create_line(0, 0, w+2, h+2, fill="red")
        x = int(event.x)
        y = int(event.y)
        print( "event x,y=",x,y )
        self.Canvas_1.create_text(x,y, text="NE", fill="green", anchor=NE)
        self.Canvas_1.create_text(x,y, text="SW", fill="magenta", anchor=SW)
    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Listbox_1_Click"
    def Listbox_1_Click(self, event): #bind method for component ID=Listbox_1
        """     Listbox:  at LabelFrame_1(1,1)"""
        pass
        # >>>>>>insert any user code below this comment for section "Listbox_1_Click"
        # replace, delete, or comment-out the following
        print( "executed method Listbox_1_Click" )

        print( "current selection(s) =",self.Listbox_1.curselection() )
        labelL = []
        for i in self.Listbox_1.curselection():
            labelL.append( self.Listbox_1.get(i))
        print( "current label(s) =",labelL )
        # use self.Listbox_1.insert(0, "item zero")
        #     self.Listbox_1.insert(index, "item i")
        #            OR
        #     self.Listbox_1.insert(END, "item end")
        #   to insert items into the list box
    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Button_2_Click"
    def Button_2_Click(self, event): #bind method for component ID=Button_2
        """      Button:  at Tab_3(3,1)"""
        pass
        # >>>>>>insert any user code below this comment for section "Button_2_Click"
        # replace, delete, or comment-out the following
        print( "executed method Button_2_Click" )

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Treeview_1_Click"
    def Treeview_1_Click(self, event): #bind method for component ID=Treeview_1
        """    Treeview:  at Tab_3(2,2)"""
        pass
        # >>>>>>insert any user code below this comment for section "Treeview_1_Click"
        # replace, delete, or comment-out the following
        print( "executed method Treeview_1_Click" )

        curItem = self.Treeview_1.focus()
        print( "current Treeview item(s) =",self.Treeview_1.item( curItem ) )
    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_2_StringVar_traceName"
    def Checkbutton_2_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton:  at Frame_1(1,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Checkbutton_2_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Checkbutton_2_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Combobox_2_StringVar_traceName"
    def Combobox_2_StringVar_Callback(self, varName, index, mode):
        """    Combobox: Mine Yours Ours : at Frame_1(2,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Combobox_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Combobox_2_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Combobox_2_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Entry_2_StringVar_traceName"
    def Entry_2_StringVar_Callback(self, varName, index, mode):
        """       Entry:  at Frame_1(3,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Entry_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Entry_2_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Entry_2_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Menubutton_1_StringVar_traceName"
    def Menubutton_1_StringVar_Callback(self, varName, index, mode):
        """  Menubutton:  at LabelFrame_2(1,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Menubutton_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Menubutton_1_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Menubutton_1_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Scale_1_StringVar_traceName"
    def Scale_1_StringVar_Callback(self, varName, index, mode):
        """       Scale: 2.5 to 7.5 : at Tab_5(2,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Scale_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Scale_1_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Scale_1_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Spinbox_1_StringVar_traceName"
    def Spinbox_1_StringVar_Callback(self, varName, index, mode):
        """     Spinbox: 1 to 10 : at Tab_5(3,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Spinbox_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Spinbox_1_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Spinbox_1_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "RadioGroup_1_StringVar_traceName"
    def RadioGroup_1_StringVar_Callback(self, varName, index, mode):
        """  RadioGroup:  at Tab_4(1,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "RadioGroup_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "RadioGroup_1_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.RadioGroup_1_StringVar.get() )
Exemple #5
0
class _auto_detect(_Dialog):

    def body(self, master):
        dialogframe = Frame(master, width=741, height=560)
        self.dialogframe = dialogframe
        dialogframe.pack()


        self.make_Canvas_1( self.dialogframe )         #      Canvas:  at Main(2,2)
        self.make_Frame_1( self.dialogframe )          #       Frame:  at Main(2,1)
        self.make_Button_1( self.Frame_1 )             #      Button: Generate Points : at Frame_1(8,1)
        self.make_Checkbutton_1( self.Frame_1 )        # Checkbutton: Replace or Add : at Frame_1(10,1)
        self.make_Checkbutton_2( self.Frame_1 )        # Checkbutton: Show Blur : at Frame_1(9,1)
        self.make_Entry_1( self.Frame_1 )              #       Entry: 0.02 : at Frame_1(5,1)
        self.make_Label_1( self.Frame_1 )              #       Label: Blur Radius : at Frame_1(0,1)
        self.make_Label_2( self.Frame_1 )              #       Label: #Generated Points : at Frame_1(2,1)
        self.make_Label_3( self.Frame_1 )              #       Label: Explore Fraction : at Frame_1(4,1)
        self.make_Label_4( self.Frame_1 )              #       Label: Masking Line Width : at Frame_1(6,1)
        self.make_Label_5( self.Frame_1 )              #       Label: Point Opacity : at Frame_1(11,1)
        self.make_Spinbox_1( self.Frame_1 )            #     Spinbox: Blur Radius : at Frame_1(1,1)
        self.make_Spinbox_2( self.Frame_1 )            #     Spinbox: 3 to 1000 : at Frame_1(3,1)
        self.make_Spinbox_3( self.Frame_1 )            #     Spinbox: 1 to 9 : at Frame_1(7,1)
        self.make_Spinbox_4( self.Frame_1 )            #     Spinbox: 1 to 255 : at Frame_1(12,1)
        self.make_Text_1( self.Frame_1 )               #        Text:  at Frame_1(13,1)

        self.dialogframe.rowconfigure(2, weight=1)
        self.dialogframe.rowconfigure(13, weight=1)
        self.dialogframe.columnconfigure(2, weight=1)

        # >>>>>>insert any user code below this comment for section "top_of_init"
        self.x, self.y, self.w, self.h = -1,-1,-1,-1
        self.dw_canv = -1
        self.dh_canv = -1
        self.need_resize = False
        
        self.d_frac = 0.02 # explore fraction normal to 1st curve estimate
        self.blur_radius = 3 # GaussianBlur radius
        self.num_points = 12 # number of point intervals to generate
        self.masking_line_size = 9 # used in (Will be kept odd)
        self.opacity = 155 # for points on drawing
        self.calc_pointL = [] # list of calculated points

        
        # bind master to <Configure> in order to handle any resizing, etc.
        # postpone self.dialog_master.bind("<Configure>", self.Master_Configure)
        self.initComplete = 0
        self.dialog_master = master
        self.dialog_master.bind('<Enter>', self.bindConfigure)
        
        # Mouse Wheel for Zooming in and out
        self.Canvas_1.bind("<MouseWheel>",self.MouseWheelHandler) # Windows Binding
        self.Canvas_1.bind("<Button-4>",self.MouseWheelHandler) # Linux Binding
        self.Canvas_1.bind("<Button-5>",self.MouseWheelHandler) # Linux Binding  
        
        self.is_dragging = False
        self.last_right_click_pos = (0,0) # any action calling Canvas_Find_Closest will set

        self.last_hover_pos = (0,0)
        self.in_canvas = False
        
        self.Canvas_1.bind("<Button-3>", self.Canvas_Begin_End_Drag)
        self.Canvas_1.bind("<B3-Motion>", self.Canvas_Drag_Axes)
        self.Canvas_1.bind("<Motion>", self.Canvas_Hover)
        self.Canvas_1.bind("<Enter>", self.Canvas_Enter)
        self.Canvas_1.bind("<Leave>", self.Canvas_Leave)
                
        self.resizable(1,1) # Linux may not respect this
        self.Canvas_1.focus_set()
        
        self.PA = deepcopy( self.dialogOptions['PA'] )
        self.PA_img = self.PA.img
        self.pointL = deepcopy( self.dialogOptions['pointL'] )
        
        self.fill_canvas()

    def fill_canvas(self):
        
        try:
            self.Canvas_1.delete("all")
        except:
            pass
        
        self.build_PA_img()
        
        self.photo_image = self.PA.get_tk_photoimage(greyscale=False, text='')
        
        self.Canvas_1.create_image(0,0, anchor=NW, image=self.photo_image )

    def build_PA_img(self):
        
        self.calc_pointL = [] # start with empty list of calculated points
        
        gray = self.PA_img.convert("L")
        w,h = self.PA_img.size
        
        rgb = Image.new('RGB', (w,h), (0,0,0))
        show_gray = Image.new('L', (w,h), 255)
        gray_mask = Image.new('L', (w,h), 0)
        rgb_mask = Image.new('L', (w,h), 0)
        
        draw_rgb = ImageDraw.Draw( rgb )
        draw_gray_mask = ImageDraw.Draw( gray_mask )
        draw_rgb_mask = ImageDraw.Draw( rgb_mask )
                
        pLL = [(P.x,P.y,P.fi,P.fj) for P in self.pointL]
        pLL.sort() # make sure increasing x
        
        fiL = []
        fjL = []
        fsL = [0.0] # approximate length along curve
        for i,pL in enumerate(pLL):
            #print(pL)
            x,y,fi,fj = pL
            fiL.append( fi )
            fjL.append( fj )
            if i>0:
                s = fsL[-1] +  ((fi-fiL[-2])**2 + (fj-fjL[-2])**2)**0.5
                fsL.append( s )
        #print( 'fsL=',fsL )
        s_total = fsL[-1]        
        
        # build interplators along 1st estimate of curve
        fjterp = InterpProp( fiL, fjL, extrapOK=True )
        fi_sterp = InterpProp( fsL, fiL, extrapOK=True )
            
            
        # draw approximate-interpolated curve
        ijL = [] # list of (i,j) for draw.line
        for i in range(101):
            s = i*s_total / 100.0
            fi = fi_sterp( s )
            
            fj = fjterp( fi )
            ijL.append( (int( w * fi ), int( h * fj )) )

        #draw_rgb.line( ijL, width=3, fill='red' )
        #draw_rgb_mask.line( ijL, width=3, fill=self.opacity )
        
        # try to eliminate line imperfections (holes in wide lines.)
        for i in [-1,0,1]:
            for j in [-1,0,1]:
                ij_newL = [(i+ii,j+jj) for ii,jj in ijL]
                draw_gray_mask.line( ij_newL, width=self.masking_line_size, fill=255 )
        
        
        # show data points
        for (x,y,fi,fj) in pLL:
            f_ipos = w * fi
            i = int( f_ipos )
            f_jpos = h * fj
            j = int( f_jpos )
            draw_rgb.rectangle(((i-4,j-4),(i+4,j+4)), fill ="blue", outline ="cyan") 
            draw_rgb_mask.rectangle(((i-4,j-4),(i+4,j+4)), fill=self.opacity, outline =self.opacity) 

        # show normal
        aspect = float(w) / float(h)
        #print('aspect=',aspect)
        
        show_gray.paste( gray, mask=gray_mask )
        show_gray = show_gray.filter( ImageFilter.GaussianBlur(radius=self.blur_radius ) ) 
        
        d = self.d_frac
        Npts = self.num_points
        for i in range(Npts + 1):
            s = i*s_total / float(Npts)
            fi = fi_sterp( s )
            fj = fjterp( fi )
            slope = -fjterp.deriv( fi ) # negative since fj=0 is at top
            #print(fi, fj, slope)
            try:
                normal = -1.0 / slope
            except:
                normal = 100.0 # any non-overflow big number should do.
            
            dfj = normal * d 
            dfi = d / aspect
            mult = d / ( dfj**2 + dfi**2 )**0.5
            dfj *= mult
            dfi *= mult
            
            fi_1 = fi - dfi
            fi_2 = fi + dfi
            
            fj_1 = fj + dfj
            fj_2 = fj - dfj
            
            i1 = int( fi_1 * w)
            j1 = int( fj_1 * h)
            
            i2 = int( fi_2 * w)
            j2 = int( fj_2 * h)
            
            draw_rgb.line( ((i1,j1),(i2,j2)), width=3, fill='magenta' )
            draw_rgb_mask.line( ((i1,j1),(i2,j2)), width=3, fill=self.opacity )
            #draw_rgb.rectangle(((i1-4,j1-4),(i1+4,j1+4)), fill ="blue", outline ="cyan") 
            
            # get 1D color array for edge-finding. (FROM show_gray)
            def get_ave_color( fi, fj ):
                i1 = int(  fi * w )
                j1 = int(  fj * h )
                c11 = show_gray.getpixel( (i1,j1) )
                return c11
            
            oneDL = []
            fi_oneDL = []
            fj_oneDL = []
            Nsteps = 100
            for n in range(Nsteps+1):
                fi = fi_1 + n*dfi*2 / Nsteps
                fj = fj_1 - n*dfj*2 / Nsteps
                oneDL.append( get_ave_color( fi, fj ) )
                fi_oneDL.append( fi )
                fj_oneDL.append( fj )
            gfilt_oneDL = gaussian_filter1d( oneDL, Nsteps/30.0 )
            
            # take the darkest points to find approximate center of line
            max_v = gfilt_oneDL.max()
            min_v = gfilt_oneDL.min()
            r = max_v - min_v
            cutoff = min_v + (max_v - min_v)*0.1
            minL = np.where(gfilt_oneDL <= cutoff )[0]
            #print( 'minL =', minL )
            
            # clamp iave into range of 0 to len(fi_oneDL)-1
            #iave = min( len(fi_oneDL)-1, max(0,np.argmin( gfilt_oneDL )))
            iave = int( sum(minL) / len(minL) )
            iave = min( len(fi_oneDL)-1, max(0,iave))
            
            fi = fi_oneDL[ iave ]
            fj = fj_oneDL[ iave ]
                        
            # use get_xy_at_fifj(self, fi, fj) in Digiplot code
            #x = self.PA.x_origin + (self.PA.xmax-self.PA.x_origin)*(fi-self.PA.fi_origin)/(self.PA.fimax-self.PA.fi_origin)
            #y = self.PA.y_origin + (self.PA.ymax-self.PA.y_origin)*(fj-self.PA.fj_origin)/(self.PA.fjmax-self.PA.fj_origin)
            x,y = self.PA.get_xy_at_fifj( fi, fj )
            
            if iave<Nsteps/4 or iave>Nsteps*3/4:
                print('Rejected fi=%g, fj=%g, x=%g, y=%g'%(fi,fj,x,y))
            else:

                f_ipos = w * fi
                i = int( f_ipos )
                f_jpos = h * fj
                j = int( f_jpos )
                draw_rgb.rectangle(((i-4,j-4),(i+4,j+4)), fill='green', outline ="green") 
                draw_rgb_mask.rectangle(((i-4,j-4),(i+4,j+4)), fill=self.opacity, outline =self.opacity) 
                
                
                self.calc_pointL.append( (x,y, fi,fj) )

        # plot selected curve
        fiL = []
        fjL = []
        fsL = [0.0] # approximate length along curve
        for i,pL in enumerate(self.calc_pointL):
            #print(pL)
            x,y,fi,fj = pL
            fiL.append( fi )
            fjL.append( fj )
            if i>0:
                s = fsL[-1] +  ((fi-fiL[-2])**2 + (fj-fjL[-2])**2)**0.5
                fsL.append( s )
        s_total = fsL[-1]        
        
        # build interplators along curve
        fjterp = InterpProp( fiL, fjL, extrapOK=True )
        fi_sterp = InterpProp( fsL, fiL, extrapOK=True )
            
        # draw curve
        ijL = [] # list of (i,j) for draw.line
        for i in range(101):
            s = i*s_total / 100.0
            fi = fi_sterp( s )
            
            fj = fjterp( fi )
            ijL.append( (int( w * fi ), int( h * fj )) )

        draw_rgb.line( ijL, width=3, fill='red' )
        draw_rgb_mask.line( ijL, width=3, fill=self.opacity )
        

        # make rgb image for display to user
        if self.Checkbutton_2_StringVar.get() == 'yes':
            show_img = show_gray.convert("RGBA")
        else:
            show_img = gray.convert("RGBA")
        show_img.paste(rgb, mask=rgb_mask)
        
        
        self.PA.img = show_img


    def MouseWheelHandler(self, event):
        #print('MouseWheelHandler event.num =', event.num)

        if event.num == 5 or event.delta < 0:
            result = -1 
            #self.PA.zoom_in(zoom_factor=0.1)
            self.PA.zoom_into_ij(event.x, event.y, zoom_factor=0.1)
        else:
            result = 1 
            #self.PA.zoom_out(zoom_factor=0.1)
            self.PA.zoom_out_from_ij(event.x, event.y, zoom_factor=0.1)
            
        self.fill_canvas()

    def Canvas_Begin_End_Drag(self, event):
        self.is_dragging = not self.is_dragging
        ix = int(event.x)
        iy = int(event.y)
        
        self.last_right_click_pos = (ix, iy)
        
    def Canvas_Drag_Axes(self, event):
        di = self.last_right_click_pos[0] - event.x
        dj = self.last_right_click_pos[1] - event.y
        self.PA.adjust_offset(di, dj)
        
        self.last_right_click_pos = (event.x, event.y)
        
        self.fill_canvas()

    def Canvas_Enter(self, event):
        if self.dw_canv > 0 and self.need_resize:
            #print('Resizing Canvas',w-self.dw_canv, h-self.dh_canv)
            self.Canvas_1.config(width=self.w-self.dw_canv, height=self.h-self.dh_canv)
            self.PA.set_canvas_wh(self.w-self.dw_canv, self.h-self.dh_canv)
            #self.fill_canvas()
            self.need_resize = False
        
        
        self.in_canvas = True
        self.fill_canvas()
                
    def Canvas_Leave(self, event):
        self.in_canvas = False
        self.fill_canvas()

    def Canvas_Hover(self, event):
        self.last_hover_pos = (event.x, event.y)
        self.fill_canvas()
            
    def bindConfigure(self, event):
        if not self.initComplete:
            #print('Init Master_Configure')
            self.dialog_master.bind("<Configure>", self.Master_Configure)
            self.initComplete = 1


    def Master_Configure(self, event):
        pass
        # replace, delete, or comment-out the following
        if event.widget != self.dialog_master:
            if self.w != -1:
                return
        #print('Master_Configure', event)
        x = int(self.winfo_x())
        y = int(self.winfo_y())
        w = int(self.winfo_width())
        h = int(self.winfo_height())
        if (self.x, self.y, self.w, self.h) == (-1,-1,-1,-1):
            self.x, self.y, self.w, self.h = x,y,w,h
            
            w_canv = int( self.Canvas_1.winfo_width() )
            h_canv = int( self.Canvas_1.winfo_height() )
            self.dw_canv = w - w_canv
            self.dh_canv = h - h_canv
            


        if self.w!=w or self.h!=h:
            #print( "Master reconfigured... make resize adjustments")
            self.w=w
            self.h=h
            self.need_resize = True
            
            #if self.dw_canv > 0:
            #    #print('Resizing Canvas',w-self.dw_canv, h-self.dh_canv)
            #    self.Canvas_1.config(width=w-self.dw_canv, height=h-self.dh_canv)
            #    self.PA.set_canvas_wh(w-self.dw_canv, h-self.dh_canv)
            #    self.fill_canvas()
        

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Canvas_1"
    def make_Canvas_1(self, frame):
        """      Canvas:  at Main(2,2)"""
        self.Canvas_1 = Canvas( frame , width="600", height="500")
        self.Canvas_1.grid(row=2, column=2, sticky="nsew")

        # >>>>>>insert any user code below this comment for section "make_Canvas_1"

        self.Canvas_1.config(bg='#ffffcc')
        self.Canvas_1.bind("<ButtonRelease-1>", self.Canvas_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Frame_1"
    def make_Frame_1(self, frame):
        """       Frame:  at Main(2,1)"""
        self.Frame_1 = Frame( frame , width="60", height="50")
        self.Frame_1.grid(row=2, column=1, sticky="ns")

        # >>>>>>insert any user code below this comment for section "make_Frame_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Button_1"
    def make_Button_1(self, frame):
        """      Button: Generate Points : at Frame_1(8,1)"""
        self.Button_1 = Button( frame , text="Generate Points", width="15")
        self.Button_1.grid(row=8, column=1)

        # >>>>>>insert any user code below this comment for section "make_Button_1"

        self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_1"
    def make_Checkbutton_1(self, frame):
        """ Checkbutton: Replace or Add : at Frame_1(10,1)"""
        self.Checkbutton_1 = Checkbutton( frame , text="Replace or Add", width="15", justify="left", anchor="w")
        self.Checkbutton_1.grid(row=10, column=1, sticky="w")
        self.Checkbutton_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_1"

        self.Checkbutton_1.configure(variable=self.Checkbutton_1_StringVar, onvalue="yes", offvalue="no")
        self.Checkbutton_1_StringVar.set("yes")
        self.Checkbutton_1_StringVar_traceName = self.Checkbutton_1_StringVar.trace_variable("w", self.Checkbutton_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_2"
    def make_Checkbutton_2(self, frame):
        """ Checkbutton: Show Blur : at Frame_1(9,1)"""
        self.Checkbutton_2 = Checkbutton( frame , text="Show Blur", width="15", justify="left", anchor="w")
        self.Checkbutton_2.grid(row=9, column=1, sticky="w")
        self.Checkbutton_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_2"

        self.Checkbutton_2.configure(variable=self.Checkbutton_2_StringVar, onvalue="yes", offvalue="no")
        self.Checkbutton_2_StringVar.set("no")
        self.Checkbutton_2_StringVar_traceName = self.Checkbutton_2_StringVar.trace_variable("w", self.Checkbutton_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Entry_1"
    def make_Entry_1(self, frame):
        """       Entry: 0.02 : at Frame_1(5,1)"""
        self.Entry_1 = Entry( frame , width="17")
        self.Entry_1.grid(row=5, column=1, sticky="e")
        self.Entry_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Entry_1"
        self.Entry_1_StringVar.set( '0.02' )
        self.Entry_1.configure(textvariable=self.Entry_1_StringVar)
        self.Entry_1_StringVar_traceName = self.Entry_1_StringVar.trace_variable("w", self.Entry_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_1"
    def make_Label_1(self, frame):
        """       Label: Blur Radius : at Frame_1(0,1)"""
        self.Label_1 = Label( frame , text="Blur Radius", width="15", anchor="w", justify="left")
        self.Label_1.grid(row=0, column=1, sticky="w")

        # >>>>>>insert any user code below this comment for section "make_Label_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_2"
    def make_Label_2(self, frame):
        """       Label: #Generated Points : at Frame_1(2,1)"""
        self.Label_2 = Label( frame , text="#Point Intervals", width="15", anchor="w", justify="left")
        self.Label_2.grid(row=2, column=1, sticky="w")

        # >>>>>>insert any user code below this comment for section "make_Label_2"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_3"
    def make_Label_3(self, frame):
        """       Label: Explore Fraction : at Frame_1(4,1)"""
        self.Label_3 = Label( frame , text="Explore Fraction", width="15", anchor="w", justify="left")
        self.Label_3.grid(row=4, column=1, sticky="w")

        # >>>>>>insert any user code below this comment for section "make_Label_3"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_4"
    def make_Label_4(self, frame):
        """       Label: Masking Line Width : at Frame_1(6,1)"""
        self.Label_4 = Label( frame , text="Masking Line Width", width="15", anchor="w", justify="left")
        self.Label_4.grid(row=6, column=1, sticky="w")

        # >>>>>>insert any user code below this comment for section "make_Label_4"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_5"
    def make_Label_5(self, frame):
        """       Label: Point Opacity : at Frame_1(11,1)"""
        self.Label_5 = Label( frame , text="Point Opacity", width="15", anchor="w", justify="left")
        self.Label_5.grid(row=11, column=1, sticky="w")

        # >>>>>>insert any user code below this comment for section "make_Label_5"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Spinbox_1"
    def make_Spinbox_1(self, frame):
        """     Spinbox: Blur Radius : at Frame_1(1,1)"""
        self.Spinbox_1 = Spinbox( frame , from_="1", to="10", text="Blur Radius", width="15")
        self.Spinbox_1.grid(row=1, column=1, sticky="e")
        self.Spinbox_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Spinbox_1"

        self.Spinbox_1.configure(textvariable=self.Spinbox_1_StringVar, from_="1", to="10")
        self.Spinbox_1_StringVar.set("3")
        self.Spinbox_1_StringVar_traceName = self.Spinbox_1_StringVar.trace_variable("w", self.Spinbox_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Spinbox_2"
    def make_Spinbox_2(self, frame):
        """     Spinbox: 3 to 1000 : at Frame_1(3,1)"""
        self.Spinbox_2 = Spinbox( frame , from_="3", to="1000", text="Spinbox_2", width="15")
        self.Spinbox_2.grid(row=3, column=1, sticky="e")
        self.Spinbox_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Spinbox_2"

        self.Spinbox_2.configure(textvariable=self.Spinbox_2_StringVar, from_="3", to="1000")
        self.Spinbox_2_StringVar.set("12")
        self.Spinbox_2_StringVar_traceName = self.Spinbox_2_StringVar.trace_variable("w", self.Spinbox_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Spinbox_3"
    def make_Spinbox_3(self, frame):
        """     Spinbox: 1 to 9 : at Frame_1(7,1)"""
        self.Spinbox_3 = Spinbox( frame , from_="1", to="9", text="Spinbox_3", width="15")
        self.Spinbox_3.grid(row=7, column=1, sticky="e")
        self.Spinbox_3_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Spinbox_3"

        self.Spinbox_3.configure(textvariable=self.Spinbox_3_StringVar, from_="1", to="25")
        self.Spinbox_3_StringVar.set("9")
        self.Spinbox_3_StringVar_traceName = self.Spinbox_3_StringVar.trace_variable("w", self.Spinbox_3_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Spinbox_4"
    def make_Spinbox_4(self, frame):
        """     Spinbox: 1 to 255 : at Frame_1(12,1)"""
        self.Spinbox_4 = Spinbox( frame , from_="1", to="255", text="Spinbox_4", width="15")
        self.Spinbox_4.grid(row=12, column=1, sticky="e")
        self.Spinbox_4_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Spinbox_4"

        self.Spinbox_4.configure(textvariable=self.Spinbox_4_StringVar, from_="10", to="255")
        self.Spinbox_4_StringVar.set("155")
        self.Spinbox_4_StringVar_traceName = self.Spinbox_4_StringVar.trace_variable("w", self.Spinbox_4_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Text_1"
    def make_Text_1(self, frame):
        """        Text:  at Frame_1(13,1)"""
        self.Text_1 = Text( frame , width="15", height="15")
        self.Text_1.grid(row=13, column=1, sticky="ns")

        # >>>>>>insert any user code below this comment for section "make_Text_1"
        self.Text_1 = Text( frame , width="15") # redefine w/o height attribute.
        self.Text_1.grid(row=13, column=1, sticky="ns")
        self.Text_1.insert('1.0', text_warn)


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Canvas_1_Click"
    def Canvas_1_Click(self, event): #bind method for component ID=Canvas_1
        """      Canvas:  at Main(2,2)"""
        pass
        # >>>>>>insert any user code below this comment for section "Canvas_1_Click"
        # replace, delete, or comment-out the following
        #print( "executed method Canvas_1_Click" )

        #print( "clicked in canvas at x,y =",event.x,event.y )
        w = int(self.Canvas_1.cget("width"))
        h = int(self.Canvas_1.cget("height"))
        #self.Canvas_1.create_rectangle((2, 2, w+1, h+1), outline="blue")
        #self.Canvas_1.create_line(0, 0, w+2, h+2, fill="red")
        #x = int(event.x)
        #y = int(event.y)
        #print( "event x,y=",x,y )
        #self.Canvas_1.create_text(x,y, text="NE", fill="green", anchor=NE)
        #self.Canvas_1.create_text(x,y, text="SW", fill="magenta", anchor=SW)
        
    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Button_1_Click"
    def Button_1_Click(self, event): #bind method for component ID=Button_1
        """      Button: Generate Points : at Frame_1(8,1)"""
        pass
        # >>>>>>insert any user code below this comment for section "Button_1_Click"
        # replace, delete, or comment-out the following
        #print( "executed method Button_1_Click" )
        
        self.fill_canvas()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_1_StringVar_traceName"
    def Checkbutton_1_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: Replace or Add : at Frame_1(10,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Checkbutton_1_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Checkbutton_1_StringVar.get() )
        
        self.Text_1.delete('1.0', END)
        if self.Checkbutton_1_StringVar.get() == 'yes':
            self.Text_1.insert('1.0', text_warn)
        else:
            self.Text_1.insert('1.0', text_info)



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_2_StringVar_traceName"
    def Checkbutton_2_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: Show Blur : at Frame_1(9,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Checkbutton_2_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Checkbutton_2_StringVar.get() )

        
        self.fill_canvas()


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Entry_1_StringVar_traceName"
    def Entry_1_StringVar_Callback(self, varName, index, mode):
        """       Entry: 0.02 : at Frame_1(5,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Entry_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Entry_1_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Entry_1_StringVar.get() )

        try:
            self.d_frac = float( self.Entry_1_StringVar.get() )
        except:
            self.d_frac = 0.02


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Spinbox_1_StringVar_traceName"
    def Spinbox_1_StringVar_Callback(self, varName, index, mode):
        """     Spinbox: Blur Radius : at Frame_1(1,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Spinbox_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Spinbox_1_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Spinbox_1_StringVar.get() )

        try:
            self.blur_radius = int( self.Spinbox_1_StringVar.get() )
        except:
            self.blur_radius = 3
        self.fill_canvas()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Spinbox_2_StringVar_traceName"
    def Spinbox_2_StringVar_Callback(self, varName, index, mode):
        """     Spinbox: 3 to 1000 : at Frame_1(3,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Spinbox_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Spinbox_2_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Spinbox_2_StringVar.get() )

        try:
            self.num_points = int( self.Spinbox_2_StringVar.get() )
        except:
            self.num_points = 20
        self.fill_canvas()


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Spinbox_3_StringVar_traceName"
    def Spinbox_3_StringVar_Callback(self, varName, index, mode):
        """     Spinbox: 1 to 9 : at Frame_1(7,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Spinbox_3_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Spinbox_3_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Spinbox_3_StringVar.get() )
        MAX_SIZE = 25
        
        new_val = int( self.Spinbox_3_StringVar.get() )
        if new_val %2 == 1:
            self.masking_line_size = new_val
        elif new_val > self.masking_line_size and new_val < MAX_SIZE:
            self.masking_line_size = new_val + 1
            self.Spinbox_3_StringVar.set( new_val+1 )
        elif new_val < self.masking_line_size and new_val > 0:
            self.masking_line_size = new_val - 1
            self.Spinbox_3_StringVar.set( new_val-1 )
        elif new_val >= MAX_SIZE:
            self.masking_line_size = MAX_SIZE
            self.Spinbox_3_StringVar.set( MAX_SIZE )
            
        #print('self.masking_line_size =',self.masking_line_size)
        self.fill_canvas()



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Spinbox_4_StringVar_traceName"
    def Spinbox_4_StringVar_Callback(self, varName, index, mode):
        """     Spinbox: 1 to 255 : at Frame_1(12,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Spinbox_4_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Spinbox_4_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Spinbox_4_StringVar.get() )

        self.opacity = int( self.Spinbox_4_StringVar.get() )


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "dialog_validate"
    def validate(self):
        self.result = {} # return a dictionary of results
    

        self.result["Checkbutton_1"] = self.Checkbutton_1_StringVar.get()
        self.result["Checkbutton_2"] = self.Checkbutton_2_StringVar.get()
        self.result["Entry_1"] = self.Entry_1_StringVar.get()
        self.result["Spinbox_1"] = self.Spinbox_1_StringVar.get()
        self.result["Spinbox_2"] = self.Spinbox_2_StringVar.get()
        self.result["Spinbox_3"] = self.Spinbox_3_StringVar.get()
        self.result["Spinbox_4"] = self.Spinbox_4_StringVar.get()

        # >>>>>>insert any user code below this comment for section "dialog_validate"
        # set values in "self.result" dictionary for return
        # for example...
        # self.result["age"] = self.Entry_2_StringVar.get() 


        self.result["replace_pts"] = self.Checkbutton_1_StringVar.get()
        self.result["calc_pointL"] = self.calc_pointL
        return 1
# TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "end"


    def apply(self):
        pass
Exemple #6
0
    def __bottom_frame(self):
        """
        Create bottom frame content
        """
        self._cbx_max_power_value = IntVar(self._tk_obj)
        self._cbx_lowball_value = IntVar(self._tk_obj)

        frame = Frame(self._tk_obj, borderwidth=1, relief=SUNKEN, bg='#fff')
        frame.grid(column=0, row=2, padx=15, pady=15, sticky=W + E)
        frame.grid_rowconfigure(0, weight=1)
        frame.grid_columnconfigure(0, weight=1)

        # headline
        txt_section = Label(frame, text="Receive RF Settings")
        txt_section.grid(columnspan=6, row=0, padx=5, pady=5, sticky=W + E)
        txt_section.configure(font=self.__FONT_HEADLINE)

        # lowball
        lab_lowball = Label(frame, text='Lowball')
        lab_lowball.grid(column=0, row=1, padx=5, pady=5, sticky=E)
        lab_lowball.configure(font=self.__FONT_STYLE)

        # @ToDo: implementation lowball
        cbx_lowball = Checkbutton(frame, state='disabled')
        cbx_lowball.grid(column=1, row=1, padx=5, pady=5, sticky=W)
        cbx_lowball.configure(onvalue=1,
                              offvalue=0,
                              variable=self._cbx_lowball_value)

        # max power
        lab_max_power = Label(frame, text='max Power')
        lab_max_power.grid(column=2, row=1, padx=5, pady=5, sticky=E)
        lab_max_power.configure(font=self.__FONT_STYLE)

        # @ToDo: implementation of max power
        cbx_max_power = Checkbutton(frame, state='disabled')
        cbx_max_power.grid(column=3, row=1, padx=5, pady=5, sticky=W)
        cbx_max_power.configure(onvalue=1,
                                offvalue=0,
                                variable=self._cbx_max_power_value)

        # receive signal
        self._btn_receive = Button(frame,
                                   text='Start receive',
                                   command=self.__action_receive_signal)
        self._btn_receive.grid(column=4, row=1, padx=5, pady=5)
        self._btn_receive.configure(font=self.__FONT_STYLE)
        self._btn_receive.bind(
            "<Enter>", lambda event: event.widget.config(fg='indian red'))
        self._btn_receive.bind("<Leave>",
                               lambda event: event.widget.config(fg='black'))

        # copy to clipboard
        self._btn_copy = Button(frame,
                                text='Copy to clipboard',
                                command=self.__action_copy_to_clipboard)
        self._btn_copy.grid(column=5, row=1, padx=5, pady=5)
        self._btn_copy.configure(font=self.__FONT_STYLE)
        self._btn_copy.bind("<Enter>",
                            lambda event: event.widget.config(fg='indian red'))
        self._btn_copy.bind("<Leave>",
                            lambda event: event.widget.config(fg='black'))

        # status
        self._stx_receive_status = ScrolledText(frame)
        self._stx_receive_status.grid(columnspan=6,
                                      row=2,
                                      padx=5,
                                      pady=5,
                                      sticky=W + E)
        self._stx_receive_status.configure(height=12,
                                           font=self.__FONT_STYLE,
                                           borderwidth=1,
                                           relief=SOLID)
Exemple #7
0
    def __top_frame(self):
        """
        Create top frame content
        """
        self._selected_modulation = StringVar(self._tk_obj)
        self._selected_channel = StringVar(self._tk_obj)
        self._selected_sync_mode = StringVar(self._tk_obj)
        self._cbx_manchester_value = IntVar(self._tk_obj)

        frame = Frame(self._tk_obj, borderwidth=1, relief=SUNKEN, bg='#fff')
        frame.grid(column=0, row=0, padx=15, pady=15, sticky=W + E)
        frame.grid_rowconfigure(0, weight=1)
        frame.grid_columnconfigure(0, weight=1)

        # headline
        lab_section = Label(frame, text="Default RF Settings")
        lab_section.grid(columnspan=6, row=0, padx=5, pady=5, sticky=W + E)
        lab_section.configure(font=self.__FONT_HEADLINE)

        # frequency
        lab_frequency = Label(frame, text='Frequency')
        lab_frequency.grid(column=0, row=1, padx=5, pady=5, sticky=E)
        lab_frequency.configure(font=self.__FONT_STYLE)

        self._ety_frequency = Entry(frame)
        self._ety_frequency.grid(column=1, row=1, padx=5, pady=5, sticky=W)
        self._ety_frequency.configure(font=self.__FONT_STYLE)
        value_frequency = self.rf_object.getFreq()
        self._ety_frequency.insert(0, int(value_frequency[0]))

        # modulation
        lab_modulation = Label(frame, text='Modulation')
        lab_modulation.grid(column=0, row=2, padx=5, pady=5, sticky=E)
        lab_modulation.configure(font=self.__FONT_STYLE)

        opm_modulation = OptionMenu(frame, self._selected_modulation,
                                    *self.__MODULATION_OPTIONS)
        opm_modulation.grid(column=1, row=2, padx=5, pady=5, sticky=W)
        opm_modulation.configure(font=self.__FONT_STYLE)
        value_modulation = self.rf_object.getMdmModulation()
        if value_modulation == 0:
            self._selected_modulation.set(self.__MODULATION_OPTIONS[1])
        elif value_modulation == 16:
            self._selected_modulation.set(self.__MODULATION_OPTIONS[2])
        elif value_modulation == 48:
            self._selected_modulation.set(self.__MODULATION_OPTIONS[3])
        elif value_modulation == 112:
            self._selected_modulation.set(self.__MODULATION_OPTIONS[4])
        else:
            self._selected_modulation.set(self.__MODULATION_OPTIONS[0])

        # channel
        lab_channel = Label(frame, text='Channel')
        lab_channel.grid(column=0, row=3, padx=5, pady=5, sticky=E)
        lab_channel.configure(font=self.__FONT_STYLE)

        sbx_channel = Spinbox(frame, state='readonly')
        sbx_channel.grid(column=1, row=3, padx=5, pady=5, sticky=W)
        sbx_channel.configure(font=self.__FONT_STYLE)
        self._selected_channel.set(self.rf_object.getChannel())
        sbx_channel.configure(from_=0,
                              to=10,
                              increment=1,
                              textvariable=self._selected_channel)

        # baud rate
        lab_baud = Label(frame, text='Baud Rate')
        lab_baud.grid(column=2, row=1, padx=5, pady=5, sticky=E)
        lab_baud.configure(font=self.__FONT_STYLE)

        self._ety_baud = Entry(frame)
        self._ety_baud.grid(column=3, row=1, padx=5, pady=5, sticky=W)
        self._ety_baud.configure(font=self.__FONT_STYLE)
        self._ety_baud.insert(0, int(self.rf_object.getMdmDRate()))

        # deviation
        lab_deviation = Label(frame, text='Deviation')
        lab_deviation.grid(column=2, row=2, padx=5, pady=5, sticky=E)
        lab_deviation.configure(font=self.__FONT_STYLE)

        self._ety_deviation = Entry(frame)
        self._ety_deviation.grid(column=3, row=2, padx=5, pady=5, sticky=W)
        self._ety_deviation.configure(font=self.__FONT_STYLE)
        self._ety_deviation.insert(0, int(self.rf_object.getMdmDeviatn()))
        self._ety_deviation.configure(state='readonly')

        # channel bandwidth
        lab_channel_bandwidth = Label(frame, text='Channel BW')
        lab_channel_bandwidth.grid(column=2, row=3, padx=5, pady=5, sticky=E)
        lab_channel_bandwidth.configure(font=self.__FONT_STYLE)

        self._ety_channel_bandwidth = Entry(frame)
        self._ety_channel_bandwidth.grid(column=3,
                                         row=3,
                                         padx=5,
                                         pady=5,
                                         sticky=W)
        self._ety_channel_bandwidth.configure(font=self.__FONT_STYLE)
        self._ety_channel_bandwidth.insert(0,
                                           int(self.rf_object.getMdmChanBW()))
        self._ety_channel_bandwidth.configure(state='readonly')

        # sync mode
        lab_sync_mode = Label(frame, text='Sync Mode')
        lab_sync_mode.grid(column=4, row=1, padx=5, pady=5, sticky=E)
        lab_sync_mode.configure(font=self.__FONT_STYLE)

        sbx_sync_mode = Spinbox(frame, state='readonly')
        sbx_sync_mode.grid(column=5, row=1, padx=5, pady=5, sticky=W)
        sbx_sync_mode.configure(font=self.__FONT_STYLE)
        self._selected_sync_mode.set(self.rf_object.getMdmSyncMode())
        sbx_sync_mode.configure(from_=0,
                                to=7,
                                increment=1,
                                textvariable=self._selected_sync_mode)

        # sync word
        lab_sync_word = Label(frame, text='Sync Word')
        lab_sync_word.grid(column=4, row=2, padx=5, pady=5, sticky=E)
        lab_sync_word.configure(font=self.__FONT_STYLE)

        self._ety_sync_word = Entry(frame)
        self._ety_sync_word.grid(column=5, row=2, padx=5, pady=5, sticky=W)
        self._ety_sync_word.configure(font=self.__FONT_STYLE)
        self._ety_sync_word.insert(0, self.rf_object.getMdmSyncWord())
        self._ety_sync_word.configure(state='readonly')

        # channel spacing
        lab_channel_spacing = Label(frame, text='Channel Spacing')
        lab_channel_spacing.grid(column=4, row=3, padx=5, pady=5, sticky=E)
        lab_channel_spacing.configure(font=self.__FONT_STYLE)

        self._ety_channel_spacing = Entry(frame)
        self._ety_channel_spacing.grid(column=5,
                                       row=3,
                                       padx=5,
                                       pady=5,
                                       sticky=W)
        self._ety_channel_spacing.configure(font=self.__FONT_STYLE)
        value_channel_spacing = self.rf_object.getMdmChanSpc()
        self._ety_channel_spacing.insert(0, int(value_channel_spacing))
        self._ety_channel_spacing.configure(state='readonly')

        # enable manchester
        lab_manchester = Label(frame, text='Enable Manchester')
        lab_manchester.grid(column=0, row=4, padx=5, pady=5, sticky=E)
        lab_manchester.configure(font=self.__FONT_STYLE)

        cbx_manchester = Checkbutton(frame)
        cbx_manchester.grid(column=1, row=4, padx=5, pady=5, sticky=W)
        if self.rf_object.getEnableMdmManchester() == 1:
            self._cbx_manchester_value.set(1)
        else:
            self._cbx_manchester_value.set(0)
        cbx_manchester.configure(onvalue=1,
                                 offvalue=0,
                                 variable=self._cbx_manchester_value)

        # save settings
        self._btn_save_settings = Button(frame,
                                         text='Save all Settings',
                                         command=self.__action_store_settings)
        self._btn_save_settings.grid(column=5, row=4, padx=5, pady=5)
        self._btn_save_settings.configure(font=self.__FONT_STYLE)
        self._btn_save_settings.bind(
            "<Enter>", lambda event: event.widget.config(fg='indian red'))
        self._btn_save_settings.bind(
            "<Leave>", lambda event: event.widget.config(fg='black'))
class ToggleFrame(Frame):
    """ Creates a toggle frame for optional functions """
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.show = IntVar()
        self.show.set(0)
        #
        if MY_OS == 'Windows':
            xpad = 0
            ypad = 5
            basefont = 10
            spacepad = 152
        elif MY_OS == 'Linux':
            xpad = 7
            ypad = 5
            basefont = 12
            spacepad = 172
        else:
            xpad = 7
            ypad = 5
            basefont = 14
            spacepad = 175
        #
        self.show_frame = Frame(self)
        self.space = Label(self.show_frame, text='')
        self.space.configure(fg=hokiestone, bg=hokiestone, relief='flat')
        self.space.grid(column=0, row=0, pady=0, padx=spacepad, sticky='e')
        self.togButton = Checkbutton(self.show_frame,
                                     text='Show Options',
                                     command=self.tog_options,
                                     variable=self.show,
                                     fg='black',
                                     bg=hokiestone,
                                     bd=4,
                                     font=('Arial', basefont),
                                     justify='left')
        self.togButton.grid(column=1, row=0, pady=0, padx=xpad, sticky='w')
        self.prompt = IntVar()
        self.prompt.set(0)
        self.promptButton = Checkbutton(self.show_frame,
                                        text='Prompt after Each Action?',
                                        variable=self.prompt,
                                        fg='black',
                                        bg=hokiestone,
                                        bd=4,
                                        font=('Arial', basefont),
                                        justify='left')
        self.promptButton.grid(column=2, row=0, pady=0, padx=xpad, sticky='w')
        #
        self.sub_frame = Frame(self)
        labl4 = Label(self.sub_frame, text='Options:')
        labl4.configure(fg='black',
                        bg=vtgray,
                        bd=0,
                        font=('Arial', basefont),
                        height=2,
                        width=9,
                        justify='center')
        labl4.grid(column=0, row=0, pady=5, padx=5, sticky='w')
        # Options checkbuttons
        # Metadata
        self.metavar = IntVar(self.sub_frame)
        meta_chk = Checkbutton(self.sub_frame,
                               text='Create min\nmetadata files',
                               variable=self.metavar,
                               fg='black',
                               bg=hokiestone,
                               relief='flat',
                               bd=4,
                               font=('Arial', basefont),
                               justify='left')
        meta_chk.grid(column=1, row=0, pady=5, padx=xpad)
        # Register objects
        self.regisvar = IntVar(self)
        regis_chk = Checkbutton(self.sub_frame,
                                text='Register\nObjects',
                                variable=self.regisvar,
                                fg='black',
                                bg=hokiestone,
                                relief='flat',
                                bd=4,
                                font=('Arial', basefont),
                                justify='left')
        regis_chk.grid(column=2, row=0, pady=5, padx=xpad)
        # Inventory
        self.invenvar = IntVar(self)
        inv_chk = Checkbutton(self.sub_frame,
                              text='Generate\n\'manifest.csv\'',
                              variable=self.invenvar,
                              fg='black',
                              bg=hokiestone,
                              relief='flat',
                              bd=4,
                              font=('Arial', basefont),
                              justify='left')
        inv_chk.grid(column=3, row=0, pady=5, padx=xpad)
        # BagIt
        self.bagitvar = IntVar(self)
        bagit_chk = Checkbutton(self.sub_frame,
                                text='BagIt\n',
                                variable=self.bagitvar,
                                fg='black',
                                bg=hokiestone,
                                relief='flat',
                                bd=4,
                                font=('Arial', basefont),
                                justify='left')
        bagit_chk.grid(column=4, row=0, pady=5, padx=xpad)
        # Tar
        self.tarvar = IntVar(self)
        tar_chk = Checkbutton(self.sub_frame,
                              text='TAR\nObjects',
                              variable=self.tarvar,
                              fg='black',
                              bg=hokiestone,
                              relief='flat',
                              bd=4,
                              font=('Arial', basefont),
                              justify='left')
        tar_chk.grid(column=5, row=0, pady=5, padx=xpad)
        # Transfer manifest
        self.transvar = IntVar(self)
        trans_chk = Checkbutton(self.sub_frame,
                                text='Transfer\nManifest',
                                variable=self.transvar,
                                fg='black',
                                bg=hokiestone,
                                relief='flat',
                                bd=4,
                                font=('Arial', basefont),
                                justify='left')
        trans_chk.grid(column=6, row=0, pady=5, padx=xpad)
        # Set defaults to "checked"
        self.metavar.set(1)
        self.regisvar.set(1)
        self.invenvar.set(1)
        self.bagitvar.set(1)
        self.tarvar.set(1)
        self.transvar.set(1)
        #
        self.sub_frame.configure(bd=2, bg=hokiestone, relief='raised')
        self.show_frame.configure(bd=2, bg=hokiestone, relief='flat')
        self.show_frame.grid(column=0, row=3, pady=0, padx=0, sticky='nsew')

    def tog_options(self):
        if self.show.get() == 1:
            self.sub_frame.grid(column=0, row=0, pady=0, padx=0, sticky='nsew')
            self.togButton.configure(text='Hide Options')
        else:
            self.sub_frame.grid_forget()
            self.togButton.configure(text='Show Options')
class _cross_platform_fonts(_Dialog):
    def body(self, master):
        dialogframe = Frame(master, width=523, height=346)
        self.dialogframe = dialogframe
        dialogframe.pack()

        self.RadioGroup_1_StringVar = StringVar()

        self.make_Entry_2(self.dialogframe)  #       Entry:  at Main(1,2)
        self.make_LabelFrame_1(
            self.dialogframe)  #  LabelFrame: Attributes : at Main(2,4)
        self.make_Label_3(
            self.dialogframe
        )  #       Label: (see sample text above) : at Main(9,1)
        self.make_Label_4(
            self.dialogframe)  #       Label: ABCD efg 123.0 : at Main(8,1)
        self.make_Label_6(
            self.dialogframe
        )  #       Label: Courier 10 normal italic underline overstrike : at Main(0,1)
        self.make_Label_7(self.dialogframe)  #       Label:  at Main(2,3)
        self.make_Label_8(
            self.dialogframe)  #       Label: System Fonts : at Main(0,5)
        self.make_Listbox_1(self.dialogframe)  #     Listbox:  at Main(2,2)
        self.make_Listbox_2(self.dialogframe)  #     Listbox:  at Main(1,5)
        self.make_RadioGroup_1(
            self.dialogframe
        )  #  RadioGroup: Cross Platform Fonts : at Main(2,1)
        self.make_Checkbutton_1(
            self.LabelFrame_1)  # Checkbutton: Bold : at LabelFrame_1(1,1)
        self.make_Checkbutton_2(
            self.LabelFrame_1)  # Checkbutton: Italic : at LabelFrame_1(2,1)
        self.make_Checkbutton_3(
            self.LabelFrame_1)  # Checkbutton: Underline : at LabelFrame_1(3,1)
        self.make_Checkbutton_4(
            self.LabelFrame_1
        )  # Checkbutton: Overstrike : at LabelFrame_1(4,1)
        self.make_Radiobutton_1(
            self.RadioGroup_1)  # Radiobutton: Courier : at RadioGroup_1(1,0)
        self.make_Radiobutton_2(
            self.RadioGroup_1)  # Radiobutton: Helvetica : at RadioGroup_1(2,0)
        self.make_Radiobutton_3(
            self.RadioGroup_1)  # Radiobutton: Times : at RadioGroup_1(3,0)
        self.make_Radiobutton_4(
            self.RadioGroup_1
        )  # Radiobutton: TkDefaultFont : at RadioGroup_1(4,0)
        self.make_Radiobutton_5(
            self.RadioGroup_1
        )  # Radiobutton: Platform Specific : at RadioGroup_1(6,0)
        self.make_Radiobutton_6(
            self.RadioGroup_1)  # Radiobutton: Symbol : at RadioGroup_1(5,0)

        self.RadioGroup_1_StringVar.set("1")
        self.RadioGroup_1_StringVar_traceName = self.RadioGroup_1_StringVar.trace_variable(
            "w", self.RadioGroup_1_StringVar_Callback)
        # >>>>>>insert any user code below this comment for section "top_of_init"

        self.RadioGroup_1_StringVar.set("2")  # make Helvetica the default
        self.current_font_name = 'Helvetica'

        self.ignore_entry_change = False  # used when Listbox sets Entry
        self.Entry_2_StringVar.set('10')

    def set_current_state(self):

        sL = [self.current_font_name]

        points = self.Entry_2_StringVar.get().strip()
        try:
            points = int(points.strip())
        except:
            points = 10
        if points:
            sL.append(points)
        else:
            sL.append(10)

        if self.Checkbutton_1_StringVar.get() == 'yes':
            sL.append('bold')
        else:
            sL.append('normal')

        if self.Checkbutton_2_StringVar.get() == 'yes':
            sL.append('italic')
        else:
            sL.append('roman')

        if self.Checkbutton_3_StringVar.get() == 'yes':
            sL.append('underline')

        if self.Checkbutton_4_StringVar.get() == 'yes':
            sL.append('overstrike')

        self.full_font_desc = tuple(sL)
        self.Label_6.configure(text=self.full_font_desc)

        self.Label_4.configure(font=self.full_font_desc)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Entry_2"
    def make_Entry_2(self, frame):
        """       Entry:  at Main(1,2)"""
        self.Entry_2 = Entry(frame, width="4")
        self.Entry_2.grid(row=1, column=2, sticky="w")
        self.Entry_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Entry_2"

        self.Entry_2.configure(textvariable=self.Entry_2_StringVar)
        self.Entry_2_StringVar_traceName = self.Entry_2_StringVar.trace_variable(
            "w", self.Entry_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_LabelFrame_1"
    def make_LabelFrame_1(self, frame):
        """  LabelFrame: Attributes : at Main(2,4)"""
        self.LabelFrame_1 = LabelFrame(frame,
                                       text="Attributes",
                                       width="60",
                                       height="50")
        self.LabelFrame_1.grid(row=2, column=4, sticky="n", rowspan="2")

        # >>>>>>insert any user code below this comment for section "make_LabelFrame_1"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_3"
    def make_Label_3(self, frame):
        """       Label: (see sample text above) : at Main(9,1)"""
        self.Label_3 = Label(frame, text="(see sample text above)", width="30")
        self.Label_3.grid(row=9, column=1, columnspan="5")

        # >>>>>>insert any user code below this comment for section "make_Label_3"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_4"
    def make_Label_4(self, frame):
        """       Label: ABCD efg 123.0 : at Main(8,1)"""
        self.Label_4 = Label(frame, text="ABCD efg 123.0", width="14")
        self.Label_4.grid(row=8, column=1, sticky="ew", columnspan="5")

        # >>>>>>insert any user code below this comment for section "make_Label_4"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_6"
    def make_Label_6(self, frame):
        """       Label: Courier 10 normal italic underline overstrike : at Main(0,1)"""
        self.Label_6 = Label(
            frame,
            text="Courier 10 normal italic underline overstrike",
            width="30",
            font="TkDefaultFont 12")
        self.Label_6.grid(row=0, column=1, sticky="ew", columnspan="4")

        # >>>>>>insert any user code below this comment for section "make_Label_6"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_7"
    def make_Label_7(self, frame):
        """       Label:  at Main(2,3)"""
        self.Label_7 = Label(frame, text="", width="3")
        self.Label_7.grid(row=2, column=3)

        # >>>>>>insert any user code below this comment for section "make_Label_7"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_8"
    def make_Label_8(self, frame):
        """       Label: System Fonts : at Main(0,5)"""
        self.Label_8 = Label(frame, text="System Fonts", width="15")
        self.Label_8.grid(row=0, column=5, sticky="s")

        # >>>>>>insert any user code below this comment for section "make_Label_8"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Listbox_1"
    def make_Listbox_1(self, frame):
        """     Listbox:  at Main(2,2)"""

        lbframe = Frame(frame)
        self.Listbox_1_frame = lbframe
        vbar = Scrollbar(lbframe, orient=VERTICAL)
        self.Listbox_1 = Listbox(lbframe,
                                 width="4",
                                 borderwidth="4",
                                 height="10",
                                 yscrollcommand=vbar.set)
        vbar.config(command=self.Listbox_1.yview)

        vbar.grid(row=0, column=1, sticky='ns')
        self.Listbox_1.grid(row=0, column=0)

        self.Listbox_1_frame.grid(row=2, column=2, sticky="nsw")

        # >>>>>>insert any user code below this comment for section "make_Listbox_1"
        self.Listbox_1.configure(
            exportselection=False)  # stay highlighted after focus leaves

        # Edit the Listbox Entries
        self.font_sizeL = [
            "%i" % i for i in (list(range(6, 17)) + list(range(18, 32, 2)) +
                               [42, 48, 54, 60, 72])
        ]

        for s in self.font_sizeL:
            self.Listbox_1.insert(END, s)

        self.Listbox_1.bind("<ButtonRelease-1>", self.Listbox_1_Click)
        self.Listbox_1.bind('<<ListboxSelect>>', self.Listbox_1_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Listbox_2"
    def make_Listbox_2(self, frame):
        """     Listbox:  at Main(1,5)"""

        lbframe = Frame(frame)
        self.Listbox_2_frame = lbframe
        vbar = Scrollbar(lbframe, orient=VERTICAL)
        self.Listbox_2 = Listbox(lbframe,
                                 width="25",
                                 height="15",
                                 yscrollcommand=vbar.set)
        vbar.config(command=self.Listbox_2.yview)

        vbar.grid(row=0, column=1, sticky='ns')
        self.Listbox_2.grid(row=0, column=0)

        self.Listbox_2_frame.grid(row=1, column=5, sticky="ns", rowspan="7")

        # >>>>>>insert any user code below this comment for section "make_Listbox_2"
        self.Listbox_2.configure(
            exportselection=False)  # stay highlighted after focus leaves

        self.sys_fonts = list(set(families()))
        self.sys_fonts.sort()

        for s in self.sys_fonts:
            self.Listbox_2.insert(END, s)

        self.Listbox_2.bind("<ButtonRelease-1>", self.Listbox_2_Click)
        self.Listbox_2.bind('<<ListboxSelect>>', self.Listbox_2_Click)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_RadioGroup_1"
    def make_RadioGroup_1(self, frame):
        """  RadioGroup: Cross Platform Fonts : at Main(2,1)"""
        self.RadioGroup_1 = LabelFrame(frame,
                                       text="Cross Platform Fonts",
                                       width="60",
                                       height="50")
        self.RadioGroup_1.grid(row=2, column=1, sticky="n", rowspan="2")

        # >>>>>>insert any user code below this comment for section "make_RadioGroup_1"

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_1"
    def make_Checkbutton_1(self, frame):
        """ Checkbutton: Bold : at LabelFrame_1(1,1)"""
        self.Checkbutton_1 = Checkbutton(frame,
                                         text="Bold",
                                         width="15",
                                         anchor="w")
        self.Checkbutton_1.grid(row=1, column=1)
        self.Checkbutton_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_1"

        self.Checkbutton_1.configure(variable=self.Checkbutton_1_StringVar,
                                     onvalue="yes",
                                     offvalue="no")
        self.Checkbutton_1_StringVar.set("no")
        self.Checkbutton_1_StringVar_traceName = self.Checkbutton_1_StringVar.trace_variable(
            "w", self.Checkbutton_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_2"
    def make_Checkbutton_2(self, frame):
        """ Checkbutton: Italic : at LabelFrame_1(2,1)"""
        self.Checkbutton_2 = Checkbutton(frame,
                                         text="Italic",
                                         width="15",
                                         anchor="w")
        self.Checkbutton_2.grid(row=2, column=1)
        self.Checkbutton_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_2"

        self.Checkbutton_2.configure(variable=self.Checkbutton_2_StringVar,
                                     onvalue="yes",
                                     offvalue="no")
        self.Checkbutton_2_StringVar.set("no")
        self.Checkbutton_2_StringVar_traceName = self.Checkbutton_2_StringVar.trace_variable(
            "w", self.Checkbutton_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_3"
    def make_Checkbutton_3(self, frame):
        """ Checkbutton: Underline : at LabelFrame_1(3,1)"""
        self.Checkbutton_3 = Checkbutton(frame,
                                         text="Underline",
                                         width="15",
                                         anchor="w")
        self.Checkbutton_3.grid(row=3, column=1)
        self.Checkbutton_3_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_3"

        self.Checkbutton_3.configure(variable=self.Checkbutton_3_StringVar,
                                     onvalue="yes",
                                     offvalue="no")
        self.Checkbutton_3_StringVar.set("no")
        self.Checkbutton_3_StringVar_traceName = self.Checkbutton_3_StringVar.trace_variable(
            "w", self.Checkbutton_3_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_4"
    def make_Checkbutton_4(self, frame):
        """ Checkbutton: Overstrike : at LabelFrame_1(4,1)"""
        self.Checkbutton_4 = Checkbutton(frame,
                                         text="Overstrike",
                                         width="15",
                                         anchor="w")
        self.Checkbutton_4.grid(row=4, column=1)
        self.Checkbutton_4_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_4"

        self.Checkbutton_4.configure(variable=self.Checkbutton_4_StringVar,
                                     onvalue="yes",
                                     offvalue="no")
        self.Checkbutton_4_StringVar.set("no")
        self.Checkbutton_4_StringVar_traceName = self.Checkbutton_4_StringVar.trace_variable(
            "w", self.Checkbutton_4_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_1"
    def make_Radiobutton_1(self, frame):
        """ Radiobutton: Courier : at RadioGroup_1(1,0)"""
        self.Radiobutton_1 = Radiobutton(frame,
                                         text="Courier",
                                         value="1",
                                         width="15",
                                         anchor="w")
        self.Radiobutton_1.grid(row=1, column=0)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_1"

        self.Radiobutton_1.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_2"
    def make_Radiobutton_2(self, frame):
        """ Radiobutton: Helvetica : at RadioGroup_1(2,0)"""
        self.Radiobutton_2 = Radiobutton(frame,
                                         text="Helvetica",
                                         value="2",
                                         width="15",
                                         anchor="w")
        self.Radiobutton_2.grid(row=2, column=0)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_2"

        self.Radiobutton_2.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_3"
    def make_Radiobutton_3(self, frame):
        """ Radiobutton: Times : at RadioGroup_1(3,0)"""
        self.Radiobutton_3 = Radiobutton(frame,
                                         text="Times",
                                         value="3",
                                         width="15",
                                         anchor="w")
        self.Radiobutton_3.grid(row=3, column=0)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_3"

        self.Radiobutton_3.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_4"
    def make_Radiobutton_4(self, frame):
        """ Radiobutton: TkDefaultFont : at RadioGroup_1(4,0)"""
        self.Radiobutton_4 = Radiobutton(frame,
                                         text="TkDefaultFont",
                                         value="4",
                                         width="15",
                                         anchor="w")
        self.Radiobutton_4.grid(row=4, column=0)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_4"

        self.Radiobutton_4.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_5"
    def make_Radiobutton_5(self, frame):
        """ Radiobutton: Platform Specific : at RadioGroup_1(6,0)"""
        self.Radiobutton_5 = Radiobutton(frame,
                                         text="Platform Specific",
                                         value="6",
                                         width="15",
                                         anchor="e")
        self.Radiobutton_5.grid(row=6, column=0)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_5"

        self.Radiobutton_5.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_6"
    def make_Radiobutton_6(self, frame):
        """ Radiobutton: Symbol : at RadioGroup_1(5,0)"""
        self.Radiobutton_6 = Radiobutton(frame,
                                         text="Symbol",
                                         value="5",
                                         width="15",
                                         anchor="w")
        self.Radiobutton_6.grid(row=5, column=0)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_6"

        self.Radiobutton_6.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Listbox_1_Click"
    def Listbox_1_Click(self, event):  #bind method for component ID=Listbox_1
        """     Listbox:  at Main(2,2)"""
        pass
        # >>>>>>insert any user code below this comment for section "Listbox_1_Click"
        # replace, delete, or comment-out the following
        #print( "executed method Listbox_1_Click" )

        #print( "current selection(s) =",self.Listbox_1.curselection() )
        labelL = []
        for i in self.Listbox_1.curselection():
            labelL.append(self.Listbox_1.get(i))
        #print( "current label(s) =",labelL )

        if labelL:
            self.ignore_entry_change = True
            self.Entry_2_StringVar.set(labelL[0])
            self.ignore_entry_change = False

        # use self.Listbox_1.insert(0, "item zero")
        #     self.Listbox_1.insert(index, "item i")
        #            OR
        #     self.Listbox_1.insert(END, "item end")
        #   to insert items into the list box

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Listbox_2_Click"
    def Listbox_2_Click(self, event):  #bind method for component ID=Listbox_2
        """     Listbox:  at Main(1,5)"""
        pass
        # >>>>>>insert any user code below this comment for section "Listbox_2_Click"
        # replace, delete, or comment-out the following
        #print( "executed method Listbox_2_Click" )

        #print( "current selection(s) =",self.Listbox_2.curselection() )
        labelL = []
        for i in self.Listbox_2.curselection():
            labelL.append(self.Listbox_2.get(i))
        #print( "current label(s) =",labelL )
        # use self.Listbox_2.insert(0, "item zero")
        #     self.Listbox_2.insert(index, "item i")
        #            OR
        #     self.Listbox_2.insert(END, "item end")
        #   to insert items into the list box

        self.RadioGroup_1_StringVar.set("6")  # make Helvetica the default
        if labelL:
            self.current_font_name = labelL[0]

        self.set_current_state()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Entry_2_StringVar_traceName"
    def Entry_2_StringVar_Callback(self, varName, index, mode):
        """       Entry:  at Main(1,2)"""
        pass

        # >>>>>>insert any user code below this comment for section "Entry_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Entry_2_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Entry_2_StringVar.get() )

        self.set_current_state()

        if self.ignore_entry_change:
            return

        # Looks like a manual change, so try to change Listbox
        sval = self.Entry_2_StringVar.get().strip()
        try:
            ival = int(sval)
        except:
            ival = 0

        if ival and (sval in self.font_sizeL):
            index = self.font_sizeL.index(sval)

            self.Listbox_1.selection_clear(0, "end")
            self.Listbox_1.select_set(index)
            self.Listbox_1.see(index)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_1_StringVar_traceName"
    def Checkbutton_1_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: Bold : at LabelFrame_1(1,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Checkbutton_1_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Checkbutton_1_StringVar.get() )

        self.set_current_state()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_2_StringVar_traceName"
    def Checkbutton_2_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: Italic : at LabelFrame_1(2,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Checkbutton_2_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Checkbutton_2_StringVar.get() )
        self.set_current_state()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_3_StringVar_traceName"
    def Checkbutton_3_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: Underline : at LabelFrame_1(3,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_3_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Checkbutton_3_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Checkbutton_3_StringVar.get() )
        self.set_current_state()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_4_StringVar_traceName"
    def Checkbutton_4_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: Overstrike : at LabelFrame_1(4,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_4_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "Checkbutton_4_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.Checkbutton_4_StringVar.get() )
        self.set_current_state()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "RadioGroup_1_StringVar_traceName"
    def RadioGroup_1_StringVar_Callback(self, varName, index, mode):
        """  RadioGroup: Cross Platform Fonts : at Main(2,1)"""
        pass

        # >>>>>>insert any user code below this comment for section "RadioGroup_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        #print( "RadioGroup_1_StringVar_Callback varName, index, mode",varName, index, mode )
        #print( "    new StringVar value =",self.RadioGroup_1_StringVar.get() )

        svar = self.RadioGroup_1_StringVar.get()

        if svar == '1':
            self.current_font_name = 'Courier'
        elif svar == '2':
            self.current_font_name = 'Helvetica'
        elif svar == '3':
            self.current_font_name = 'Times'
        elif svar == '4':
            self.current_font_name = 'TkDefaultFont'
        elif svar == '5':
            self.current_font_name = 'Symbol'

        elif svar == '6':
            labelL = []
            for i in self.Listbox_2.curselection():
                labelL.append(self.Listbox_2.get(i))
            if labelL:
                self.current_font_name = labelL[0]

        self.set_current_state()

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "dialog_validate"
    def validate(self):
        self.result = {}  # return a dictionary of results

        self.result["Entry_2"] = self.Entry_2_StringVar.get()
        self.result["Checkbutton_1"] = self.Checkbutton_1_StringVar.get()
        self.result["Checkbutton_2"] = self.Checkbutton_2_StringVar.get()
        self.result["Checkbutton_3"] = self.Checkbutton_3_StringVar.get()
        self.result["Checkbutton_4"] = self.Checkbutton_4_StringVar.get()
        self.result["RadioGroup_1"] = self.RadioGroup_1_StringVar.get()

        # >>>>>>insert any user code below this comment for section "dialog_validate"
        # set values in "self.result" dictionary for return
        # for example...
        # self.result["age"] = self.Entry_2_StringVar.get()

        self.result = {}
        t = self.full_font_desc
        self.result["full_font_desc"] = t  # return the tuple
        self.result["full_font_str"] = t[0].replace(
            ' ', '\ ') + ' %i ' % t[1] + ' '.join(t[2:])

        return 1


# TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "end"

    def apply(self):
        pass
Exemple #10
0
class Edit_Properties_Dialog(_Dialog):

    def body(self, master):
        dialogframe = Frame(master, width=439, height=428)
        dialogframe.pack()
        self.dialogframe = dialogframe

        self.Delete_Checkbutton = Checkbutton(dialogframe,text="Check Here to Delete Widget", width="15")
        
        self.Delete_Checkbutton.grid(row=0, column=1, columnspan=3, sticky=W+E+N+S)
        
        self.Delete_Checkbutton_StringVar = StringVar()
        self.Delete_Checkbutton_StringVar.set("no")
        self.Delete_Checkbutton.configure(variable=self.Delete_Checkbutton_StringVar, onvalue="yes", offvalue="no")
        
        self.name_labelL = []
        self.val_entryL = []
        self.val_strvarL = []
        self.def_labelL = []
        self.cboxD = {} # index=row: value=Combobox (if any)
        self.cbox_svarD = {}# index=Combobox Widget Object: value=Combobox StringVar (if any)
        self.val_crossrefD = {}# index=Combobox Widget Object: value=index of val_strvarL
        
        keyL = sorted( self.dialogOptionsD.keys() )
        
        keyL = [k for k in keyL if k not in OMIT_ATTR]
        self.val_strvarD = {} # index=key: value=StringVar
        
        for i,key in enumerate( keyL ):
            row = 3 + i
            val, desc = self.dialogOptionsD[ key ]
            
            self.name_labelL.append( Label(dialogframe,text=key) )
            
            self.val_entryL.append( Entry(dialogframe) )
            self.val_strvarL.append( StringVar() )
            self.val_entryL[-1].configure(textvariable=self.val_strvarL[-1])
            self.val_strvarL[-1].set( val )
            self.val_strvarD[key] = self.val_strvarL[-1] # build xref by key to StringVar
            
            self.def_labelL.append( Label(dialogframe,text=desc) )
        

            self.name_labelL[-1].grid(row=row, column=1, sticky=E)
            self.val_entryL[-1].grid(row=row, column=2)
            
            if key.lower().endswith("ground"): # i.e. a color 
                f = Frame(dialogframe)
                btn = Button(f, text="Color", command=lambda N=i: self.get_color( N ) )
                btn.grid(row=0, column=1)
                btn = Button(f, text="Name", command=lambda N=i: self.get_named_color( N ) )
                btn.grid(row=0, column=0)
                f.grid(row=row, column=0, sticky=E)
                
            elif key.lower()=="font":
                btn = Button(dialogframe, text="Font ", command=lambda N=i: self.get_font( N ) )
                btn.grid(row=row, column=0, sticky=E)
                
            self.def_labelL[-1].grid(row=row, column=3, sticky=W)
            
            if key in WidgetPropertyDefinitionsD:
                long_def_label = Label(dialogframe,text=WidgetPropertyDefinitionsD[key])
                long_def_label.grid(row=row, column=4, sticky=W)
                
                optionsL = get_definition_optionsL( key )
                if optionsL:
                    svar = StringVar()
                    self.cboxD[i] = Combobox(dialogframe, values=optionsL, width=7, textvariable=svar)
                    #                         validatecommand=lambda N=i: self.get_option(N))
                    self.cboxD[i].grid(row=row, column=0, sticky=E)
                    
                    self.cbox_svarD[ self.cboxD[i] ] = svar
                    self.cbox_svarD[ self.cboxD[i] ].set( val )
                    self.val_crossrefD[ self.cboxD[i] ] = i
                    
                    self.cboxD[i].bind("<<ComboboxSelected>>", self.get_option )

        #self.resizable(0,0) # Linux may not respect this
        if 'background' in self.dialogOptionsD and 'foreground' in self.dialogOptionsD:
            
            btn = Button(dialogframe, text="Set Both bg and fg Named Colors", command=self.Get_fg_bg_Click )
            btn.grid(row=row+1, column=0, sticky=E, columnspan=3)
            
            btn = Button(dialogframe, text="Set Both bg and fg by Contrast", command=self.Get_fg_bg_CR_Click )
            btn.grid(row=row+2, column=0, sticky=E, columnspan=3)
            
    def Get_fg_bg_CR_Click(self):
        dialog = contrast_color_picker(self.parent, title="Get Foreground and Background Colors")
        if dialog.result is not None:
            cstrbg = dialog.result["bg_color_str"]
            cstrfg = dialog.result["fg_color_str"]
            self.val_strvarD['foreground'].set( cstrfg )
            self.val_strvarD['background'].set( cstrbg )
            
    def Get_fg_bg_Click(self):
        dialog = fg_bg_color_picker(self.parent, title="Get Foreground and Background Colors")
        if dialog.result is not None:
            (_, _, _, _, _, _, cstrbg, namebg) = dialog.result["bg_color"]
            (_, _, _, _, _, _, cstrfg, namefg) = dialog.result["fg_color"]
            self.val_strvarD['foreground'].set( cstrfg )
            self.val_strvarD['background'].set( cstrbg )

    def get_option(self, event):
        i = self.val_crossrefD[ event.widget ]
        #print('get_option for %i ='%i , self.cbox_svarD[ event.widget ].get() )
        self.val_strvarL[i].set( self.cbox_svarD[ event.widget ].get() )

    def get_font(self, N):
        dialog = get_cross_platform_font(self.parent, title="Get Font")
        if dialog.result is not None:
            font_str = dialog.result['full_font_str']
                
            self.val_strvarL[N].set( font_str )
        
    def get_named_color(self, N):
        dialog = named_color_picker(self.parent, title="Get Named Color")
        if dialog.result is not None:
            (_, _, _, _, _, _, cstr, name) = dialog.result["named_color"]
            self.val_strvarL[N].set( cstr )

    def get_color(self, N):
        ctup,cstr = tkinter.colorchooser.askcolor(title='Selected Color')
        if cstr:
            self.val_strvarL[N].set( cstr )
        

    def validate(self):
        """Return ONLY changes made to default values"""
        self.result = {} # return a dictionary of results
        
        # check for delete command
        if self.Delete_Checkbutton_StringVar.get() == "yes":

            msg = "Do you really want to delete %s?"%self.my_title

            child_widget_list = self.dialogOptionsD.get('child_widget_list',[])
            if len(child_widget_list) > 0:
                sL = [ '\n\n%s contains %i other widgets\n\n'%(self.my_title, len(child_widget_list)) ]
                
                for name in child_widget_list:
                    sL.append( '%s\n'%name )
                msg = msg + ''.join(sL)
            
            really = tkinter.messagebox.askyesno( "Delete %s ?"%self.my_title, msg )
            #print("really = ", really)
            if really:
                self.result["DeleteWidget"] = "yes"
        
        #self.name_labelL, self.val_entryL, self.val_strvarL, self.def_labelL,
        keyL = sorted( self.dialogOptionsD.keys() )
        
        keyL = [k for k in keyL if k not in OMIT_ATTR]
        
        for i,key in enumerate( keyL ):
            
            val, desc = self.dialogOptionsD[ key ]
            if str(val) != str(self.val_strvarL[i].get()):
                self.result[key] = str(self.val_strvarL[i].get())
            
        return 1

    def apply(self):
        #print( 'apply called in edit_Dialog' )
        pass
Exemple #11
0
def youtube_dl_launcher_for_ffmpegaudioencoder():
    # Imports----------------------------------------------------------------------------------------------------------
    from tkinter import (filedialog, StringVar, Menu, E, W, N, S, LabelFrame,
                         NORMAL, END, DISABLED, Checkbutton, Label, ttk,
                         scrolledtext, messagebox, OptionMenu, Toplevel, WORD,
                         Entry, Button, HORIZONTAL, SUNKEN, Text)
    import pyperclip, pathlib, threading, yt_dlp
    from re import sub
    from configparser import ConfigParser

    global main

    # --------------------------------------------------------------------------------------------------------- Imports

    # Main Gui & Windows ----------------------------------------------------------------------------------------------
    def main_exit_function():  # Asks if the user is ready to exit
        confirm_exit = messagebox.askyesno(
            title='Prompt',
            message="Are you sure you want to exit the program?\n\n"
            "     Note: This will end all current tasks!",
            parent=main)
        if confirm_exit:  # If user selects Yes - destroy window
            main.destroy()

    # Main UI window --------------------------------------------------------------------------------------------------
    try:  # Checks rather or not the youtube-dl-gui window is already open
        if main is not None or Toplevel.winfo_exists(main):
            main.lift(
            )  # If youtube-dl-gui window exists then bring to top of all other windows

    except:  # If youtube-dl-gui does not exist, create it...
        if not combined_with_ffmpeg_audio_encoder:
            from tkinter import Tk, PhotoImage
            main = Tk()  # Make full tkinter loop if standalone
            main.iconphoto(
                True, PhotoImage(file="Runtime/Images/Youtube-DL-Gui.png"))
        if combined_with_ffmpeg_audio_encoder:
            main = Toplevel()  # Make toplevel loop if NOT standalone
        main.title("Simple-Youtube-DL-Gui v1.21")
        main.configure(background="#434547")
        window_height = 500
        window_width = 610
        screen_width = main.winfo_screenwidth()
        screen_height = main.winfo_screenheight()
        x_coordinate = int((screen_width / 2) - (window_width / 2))
        y_coordinate = int((screen_height / 2) - (window_height / 2))
        main.geometry(
            f"{window_width}x{window_height}+{x_coordinate}+{y_coordinate}")
        main.protocol('WM_DELETE_WINDOW', main_exit_function)

        for n in range(4):  # Loop to specify the needed column/row configures
            main.grid_columnconfigure(n, weight=1)
        for n in range(5):
            main.grid_rowconfigure(n, weight=1)

        # The entire top bar/menu is only present during standalone version -------------------------------------------
        if not combined_with_ffmpeg_audio_encoder:
            my_menu_bar = Menu(main, tearoff=0)
            main.config(menu=my_menu_bar)
            file_menu = Menu(my_menu_bar,
                             tearoff=0,
                             activebackground='dim grey')
            my_menu_bar.add_cascade(label='File', menu=file_menu)
            file_menu.add_command(
                label='Exit', command=main_exit_function)  # Exits the program
            options_menu = Menu(my_menu_bar,
                                tearoff=0,
                                activebackground='dim grey')
            my_menu_bar.add_cascade(label='Options', menu=options_menu)

            def set_ffmpeg_path():
                global ffmpeg
                path = filedialog.askopenfilename(
                    title='Select Location to "ffmpeg.exe"',
                    initialdir='/',
                    filetypes=[('ffmpeg', 'ffmpeg.exe')])
                if path == '':
                    pass
                elif path != '':
                    ffmpeg = str(pathlib.Path(path))
                    config.set('ffmpeg_path', 'path', ffmpeg)
                    with open(config_file, 'w') as configfile:
                        config.write(configfile)

            options_menu.add_command(label='Set path to FFMPEG',
                                     command=set_ffmpeg_path)

            options_menu.add_separator()

            def reset_config():
                msg = messagebox.askyesno(
                    title='Warning',
                    message=
                    'Are you sure you want to reset the config.ini file settings?'
                )
                if not msg:
                    pass
                if msg:
                    try:
                        config.set('ffmpeg_path', 'path', '')
                        with open(config_file, 'w') as configfile:
                            config.write(configfile)
                        messagebox.showinfo(
                            title='Prompt',
                            message='Please restart the program')
                    except:
                        pass
                    main.destroy()

            options_menu.add_command(label='Reset Configuration File',
                                     command=reset_config)

            from Packages.about import openaboutwindow

            def open_browser_for_ffmpeg():
                import webbrowser
                webbrowser.open_new_tab(
                    'https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z'
                )

            help_menu = Menu(my_menu_bar,
                             tearoff=0,
                             activebackground="dim grey")
            my_menu_bar.add_cascade(label="Help", menu=help_menu)
            help_menu.add_command(label="Download FFMPEG",
                                  command=open_browser_for_ffmpeg)
            help_menu.add_separator()
            help_menu.add_command(label="About", command=openaboutwindow)
        # ------------------------------------------- The entire top bar/menu is only present during standalone version

        # Bundled Apps ------------------------------------------------------------------------------------------------
        config_file = 'Runtime/config.ini'  # Defines location of config.ini
        config = ConfigParser()
        config.read(config_file)

        # This creates the config file if on the standalone version ---------------------------------------------------
        if not combined_with_ffmpeg_audio_encoder:
            if not config.has_section(
                    'ffmpeg_path'):  # Create config parameters
                config.add_section('ffmpeg_path')
            if not config.has_option('ffmpeg_path', 'path'):
                config.set('ffmpeg_path', 'path', '')
            try:
                with open(config_file, 'w') as configfile:
                    config.write(configfile)
            except:
                messagebox.showinfo(
                    title='Error',
                    message=
                    'Could Not Write to config.ini file, delete and try again')
        # --------------------------------------------------- This creates the config file if on the standalone version

        # Define location of FFMPEG in a variable ---------------------------------------------------------------------
        ffmpeg = pathlib.Path(config['ffmpeg_path']['path'].replace('"', ''))
        # --------------------------------------------------------------------- Define location of FFMPEG in a variable

        # Code needed to add location of ffmpeg.exe in the event it's missing for standalone version ------------------
        if not combined_with_ffmpeg_audio_encoder:
            if not pathlib.Path(ffmpeg).is_file(
            ):  # Checks config for bundled app paths path ------------------------

                def check_ffmpeg(
                ):  # FFMPEG -------------------------------------------------------------------------
                    global ffmpeg
                    import shutil

                    def write_path_to_ffmpeg(
                    ):  # Writes path to ffmpeg to the config.ini file
                        try:
                            config.set('ffmpeg_path', 'path', ffmpeg)
                            with open(config_file, 'w') as configfile:
                                config.write(configfile)
                        except:
                            pass

                    if shutil.which('ffmpeg') is not None:
                        ffmpeg = str(pathlib.Path(
                            shutil.which('ffmpeg'))).lower()
                        messagebox.showinfo(
                            title='Prompt!',
                            message='ffmpeg.exe found on system PATH, '
                            'automatically setting path to location.\n\n'
                            'Note: This can be changed in the config.ini file'
                            ' or in the Options menu')
                        if pathlib.Path("Apps/ffmpeg/ffmpeg.exe").is_file():
                            rem_ffmpeg = messagebox.askyesno(
                                title='Delete Included ffmpeg?',
                                message=
                                'Would you like to delete the included FFMPEG?'
                            )
                            if rem_ffmpeg:
                                try:
                                    shutil.rmtree(
                                        str(pathlib.Path("Apps/ffmpeg")))
                                except:
                                    pass
                        write_path_to_ffmpeg()
                    elif pathlib.Path("Apps/ffmpeg/ffmpeg.exe").is_file():
                        messagebox.showinfo(
                            title='Info',
                            message='Program will use the included '
                            '"ffmpeg.exe" located in the "Apps" folder')
                        ffmpeg = str(pathlib.Path("Apps/ffmpeg/ffmpeg.exe"))
                        write_path_to_ffmpeg()
                    else:
                        error_prompt = messagebox.askyesno(
                            title='Error!',
                            message='Cannot find ffmpeg, '
                            'please navigate to "ffmpeg.exe"')
                        if not error_prompt:
                            messagebox.showerror(
                                title='Error!',
                                message=
                                'Program requires ffmpeg.exe to work correctly'
                            )
                            main.destroy()
                        if error_prompt:
                            set_ffmpeg_path()
                            if not pathlib.Path(ffmpeg).is_file():
                                messagebox.showerror(
                                    title='Error!',
                                    message=
                                    'Program requires ffmpeg.exe to work correctly'
                                )
                                main.destroy()

                check_ffmpeg(
                )  # FFMPEG ------------------------------------------------------------------------------
        # ------------------------------------------------------------------------------------------------ Bundled Apps
        # ------------------ Code needed to add location of ffmpeg.exe in the event it's missing for standalone version

        # Link Frame --------------------------------------------------------------------------------------------------
        link_frame = LabelFrame(main, text=' Paste Link ')
        link_frame.grid(row=0,
                        columnspan=4,
                        sticky=E + W,
                        padx=20,
                        pady=(10, 10))
        link_frame.configure(fg="white", bg="#434547", bd=3)

        link_frame.rowconfigure(1, weight=1)
        link_frame.columnconfigure(0, weight=1)
        link_frame.columnconfigure(1, weight=1)

        # -------------------------------------------------------------------------------------------------- Link Frame

        # Options Frame -----------------------------------------------------------------------------------------------
        options_frame = LabelFrame(main, text=' Options ')
        options_frame.grid(row=2,
                           columnspan=4,
                           sticky=E + W,
                           padx=20,
                           pady=(10, 10))
        options_frame.configure(fg="white", bg="#434547", bd=3)

        options_frame.rowconfigure(1, weight=1)
        options_frame.columnconfigure(0, weight=1)
        options_frame.columnconfigure(1, weight=1)

        # ----------------------------------------------------------------------------------------------- Options Frame

        # Input Frame -------------------------------------------------------------------------------------------------
        global link_input_label
        input_frame = LabelFrame(main, text=' Input ')
        input_frame.grid(row=1,
                         columnspan=4,
                         sticky=E + W,
                         padx=20,
                         pady=(4, 10))
        input_frame.configure(fg="white", bg="#434547", bd=3)
        input_frame.rowconfigure(1, weight=1)
        input_frame.columnconfigure(0, weight=1)
        input_frame.columnconfigure(1, weight=1)
        link_input_label = Label(
            input_frame,
            text='Please Paste Link Above and Select "Add Link"',
            background="#434547",
            foreground="white",
            height=1,
            font=("Helvetica", 10))
        link_input_label.grid(row=0,
                              column=0,
                              columnspan=4,
                              padx=8,
                              pady=(4, 7),
                              sticky=W + E)

        # ------------------------------------------------------------------------------------------------- Input Frame

        # File Output -------------------------------------------------------------------------------------------------
        def file_save():
            global VideoOutput
            save_entry.config(state=NORMAL)  #
            save_entry.delete(
                0, END
            )  # This function clears entry box in order to add new link to entry box
            save_entry.config(state=DISABLED)  #
            VideoOutput = filedialog.askdirectory(
                parent=main
            )  # Pop up window to choose a save directory location
            if VideoOutput:
                save_for_entry = '"' + VideoOutput + '/"'  # Completes save directory and adds quotes
                save_entry.config(state=NORMAL)  #
                save_entry.insert(
                    0, save_for_entry)  # Adds download_link to entry box
                save_entry.config(state=DISABLED)  #
                start_job_btn.config(state=NORMAL)  # Enables Button

        # ------------------------------------------------------------------------------------------------- File Output

        # Best Video Function -----------------------------------------------------------------------------------------
        def set_video_only():
            if video_only.get(
            ) == 'on':  # If video checkbutton is checked enable video options menu and set audio off
                highest_quality_audio_only.set('')
                video_menu_options_menu.config(state=NORMAL)
                audio_menu_options_menu.config(state=DISABLED)
                audio_menu_options.set('Extract Only')
            if video_only.get(
            ) != 'on':  # If not checked, set video_only to on
                video_only.set(
                    'on'
                )  # This prevents you from being able to de-select the check button

        # ----------------------------------------------------------------------------------------- Audio Only Function
        def highest_quality_audio_only_toggle():
            if highest_quality_audio_only.get(
            ) == 'on':  # If audio checkbutton is checked
                video_only.set(
                    '')  # enables video options menu and set audio to off
                video_menu_options_menu.config(state=DISABLED)
                audio_menu_options_menu.config(state=NORMAL)
            if highest_quality_audio_only.get(
            ) != 'on':  # If not checked, set audio_only to on
                highest_quality_audio_only.set(
                    'on'
                )  # This prevents you from being able to de-select the check button

        # Video Only Checkbutton --------------------------------------------------------------------------------------
        video_only = StringVar()
        video_only_checkbox = Checkbutton(
            options_frame,
            text='Best Video + Audio\nMuxed File',
            variable=video_only,
            onvalue='on',
            offvalue='',
            command=set_video_only,
            takefocus=False)
        video_only_checkbox.grid(row=0,
                                 column=1,
                                 columnspan=1,
                                 rowspan=1,
                                 padx=10,
                                 pady=6,
                                 sticky=N + S + E + W)
        video_only_checkbox.configure(background="#434547",
                                      foreground="white",
                                      activebackground="#434547",
                                      activeforeground="white",
                                      selectcolor="#434547",
                                      font=("Helvetica", 12))
        video_only.set('on')  # Enables Best Video by default

        # -------------------------------------------------------------------------------------- Video Only Checkbutton

        # Highest Quality Audio Only ----------------------------------------------------------------------------------
        highest_quality_audio_only = StringVar()
        highest_quality_audio_only_checkbox = Checkbutton(
            options_frame,
            text='Audio Only',
            variable=highest_quality_audio_only,
            onvalue='on',
            offvalue='',
            command=highest_quality_audio_only_toggle,
            takefocus=False)
        highest_quality_audio_only_checkbox.grid(row=0,
                                                 column=2,
                                                 columnspan=1,
                                                 rowspan=1,
                                                 padx=10,
                                                 pady=3,
                                                 sticky=N + S + E + W)
        highest_quality_audio_only_checkbox.configure(
            background="#434547",
            foreground="white",
            activebackground="#434547",
            activeforeground="white",
            selectcolor="#434547",
            font=("Helvetica", 12))
        highest_quality_audio_only.set('')  # Disables audio only by default

        # ---------------------------------------------------------------------------------- Highest Quality Audio Only

        # Download Rate -----------------------------------------------------------------------------------------------
        def download_rate_menu_hover(e):
            download_rate_menu["bg"] = "grey"
            download_rate_menu["activebackground"] = "grey"

        def download_rate_menu_hover_leave(e):
            download_rate_menu["bg"] = "#23272A"

        download_rate = StringVar(main)
        download_rate_choices = {
            'Unlimited': 131072000000000,
            '10 - KiB      (Slowest)': 1280,
            '50 - KiB': 6400,
            '100 - KiB': 12800,
            '250 - KiB': 32000,
            '500 - KiB': 64000,
            '750 - KiB': 96000,
            '1 - MiB': 131072,
            '5 - MiB': 655360,
            '10 - MiB': 1310720,
            '30 - MiB': 3932160,
            '50 - MiB': 6553600,
            '100 - MiB': 13107200,
            '250 - MiB': 32768000,
            '500 - MiB': 65536000,
            '750 - MiB': 98304000,
            '1000 - MiB  (Fastest)': 13107200000
        }
        download_rate_menu_label = Label(options_frame,
                                         text="Download Rate :",
                                         background="#434547",
                                         foreground="white")
        download_rate_menu_label.grid(row=0,
                                      column=0,
                                      columnspan=1,
                                      padx=10,
                                      pady=(3, 10),
                                      sticky=W + E)
        download_rate_menu = OptionMenu(options_frame, download_rate,
                                        *download_rate_choices.keys())
        download_rate_menu.config(background="#23272A",
                                  foreground="white",
                                  highlightthickness=1,
                                  width=15)
        download_rate_menu.grid(row=1,
                                column=0,
                                columnspan=1,
                                padx=10,
                                pady=(3, 20))
        download_rate.set('Unlimited')
        download_rate_menu["menu"].configure(activebackground="dim grey")
        download_rate_menu.bind("<Enter>", download_rate_menu_hover)
        download_rate_menu.bind("<Leave>", download_rate_menu_hover_leave)

        # ----------------------------------------------------------------------------------------------- Download Rate

        # Video Options -----------------------------------------------------------------------------------------------
        def video_menu_options_menu_hover(e):
            video_menu_options_menu["bg"] = "grey"
            video_menu_options_menu["activebackground"] = "grey"

        def video_menu_options_menu_hover_leave(e):
            video_menu_options_menu["bg"] = "#23272A"

        video_menu_options = StringVar(main)
        video_menu_options_choices = {
            '(bv+ba/b) Best video + audio format '
            'and combine both, or download best combined format':
            'bv+ba/b',
            '(Same as above with video up to 480p)':
            'bv*[height<=480]+ba/b[height<=480] / wv*+ba/w',
            '(Same as above with video up to 720p)':
            'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w',
            '(Same as above with video up to 1080p)':
            'bv*[height<=1080]+ba/b[height<=1080] / wv*+ba/w',
            '(Same as above with video up to 1440p)':
            'bv*[height<=1440]+ba/b[height<=1440] / wv*+ba/w',
            '(Same as above with video up to 2160p)':
            'bv*[height<=2160]+ba/b[height<=2160] / wv*+ba/w',
            '(Default) (bv*+ba/b) Best video and if missing audio, '
            'merge it with best available audio':
            'bv*+ba/b',
            '(bv) Best video only':
            'bv',
            'Download the best h264 video, '
            'or best video if no such codec':
            '(bv * +ba / b)[vcodec ^= avc1] / (bv * +ba / b)'
        }
        video_menu_options_menu = OptionMenu(
            options_frame, video_menu_options,
            *video_menu_options_choices.keys())
        video_menu_options_menu.config(background="#23272A",
                                       foreground="white",
                                       highlightthickness=1,
                                       width=15,
                                       anchor=W)
        video_menu_options_menu.grid(row=1,
                                     column=1,
                                     columnspan=1,
                                     padx=10,
                                     pady=(3, 20))
        video_menu_options.set(
            '(Default) (bv*+ba/b) Best video and if missing audio, '
            'merge it with best available audio')
        video_menu_options_menu["menu"].configure(activebackground="dim grey")
        video_menu_options_menu.bind("<Enter>", video_menu_options_menu_hover)
        video_menu_options_menu.bind("<Leave>",
                                     video_menu_options_menu_hover_leave)

        # ----------------------------------------------------------------------------------------------- Video Options

        # Audio Options -----------------------------------------------------------------------------------------------
        def audio_menu_options_menu_hover(e):
            audio_menu_options_menu["bg"] = "grey"
            audio_menu_options_menu["activebackground"] = "grey"

        def audio_menu_options_menu_hover_leave(e):
            audio_menu_options_menu["bg"] = "#23272A"

        audio_menu_options = StringVar(main)
        audio_menu_options_choices = {
            'Extract Only': '',
            'Encode to mp3': 'mp3',
            'Encode to flac': 'flac',
            'Encode to m4a': 'm4a',
            'Encode to opus': 'opus',
            'Encode to vorbis': 'vorbis',
            'Encode to wav': 'wav'
        }
        audio_menu_options_menu = OptionMenu(
            options_frame, audio_menu_options,
            *audio_menu_options_choices.keys())
        audio_menu_options_menu.config(background="#23272A",
                                       foreground="white",
                                       highlightthickness=1,
                                       width=15,
                                       anchor=W,
                                       state=DISABLED)
        audio_menu_options_menu.grid(row=1,
                                     column=2,
                                     columnspan=1,
                                     padx=10,
                                     pady=(3, 20))
        audio_menu_options.set('Extract Only')
        audio_menu_options_menu["menu"].configure(activebackground="dim grey")
        audio_menu_options_menu.bind("<Enter>", audio_menu_options_menu_hover)
        audio_menu_options_menu.bind("<Leave>",
                                     audio_menu_options_menu_hover_leave)

        # ----------------------------------------------------------------------------------------------- Audio Options

        # Add Link to variable ----------------------------------------------------------------------------------------
        def apply_link():
            global download_link, link_input_label, extracted_title_name
            link_entry.config(state=NORMAL)  #
            link_entry.delete(
                0, END
            )  # This function clears entry box in order to add new link to entry box
            link_entry.config(state=DISABLED)  #
            download_link = text_area.get(1.0, END).rstrip(
                "\n")  # Pasted download link and strips the unneeded newline
            text_area.delete(
                1.0, END
            )  # Deletes entry box where you pasted your link as it stores it into var
            link_entry.config(state=NORMAL)  #
            link_entry.insert(0,
                              download_link)  # Adds download_link to entry box
            link_entry.config(state=DISABLED)  #
            save_btn.config(state=NORMAL)  #
            try:  # The code below checks link input for the title and adds it to a variable for use with the gui
                with yt_dlp.YoutubeDL({'noplaylist': True}) as ydl:
                    dl_link_input = ydl.extract_info(download_link,
                                                     download=False)
                    string_one = sub('[^a-zA-Z0-9 \n]', '',
                                     dl_link_input['title'])
                    string_two = " ".join(string_one.split())
                    extracted_title_name = pathlib.Path(
                        string_two[:128]).with_suffix('')
            except:
                extracted_title_name = download_link
            link_input_label.configure(text=extracted_title_name)

        # ---------------------------------------------------------------------------------------------------- Add Link

        # Start Job ---------------------------------------------------------------------------------------------------
        def start_job(
        ):  # This is the progress window and everything that has to do with actually processing the file
            global download_link

            def close_encode():
                confirm_exit = messagebox.askyesno(
                    title='Prompt',
                    message="Are you sure you want to stop progress?",
                    parent=window)
                if confirm_exit:  # If user selects 'Yes' to the above message prompt, destroy the window in question
                    window.destroy()

            def close_window(
            ):  # This thread is needed in order to close the window while the GUI is processing a file
                thread = threading.Thread(target=close_encode)
                thread.start()

            window = Toplevel(main)  # Programs download window
            window.title(
                extracted_title_name
            )  # Takes extracted_title_name and adds it as the windows title
            window.configure(background='#434547')
            encode_label = Label(window,
                                 text='- ' * 22 + 'Progress ' + '- ' * 22,
                                 font=('Times New Roman', 14),
                                 background='#434547',
                                 foreground='white')
            encode_label.grid(column=0, columnspan=2, row=0)
            window.grid_columnconfigure(0, weight=1)
            window.grid_rowconfigure(0, weight=1)
            window.grid_rowconfigure(1, weight=1)
            window.protocol('WM_DELETE_WINDOW', close_window)
            window.geometry('600x140')
            encode_window_progress = Text(window,
                                          height=2,
                                          relief=SUNKEN,
                                          bd=3)
            encode_window_progress.grid(row=1,
                                        column=0,
                                        columnspan=2,
                                        pady=(10, 6),
                                        padx=10,
                                        sticky=E + W)
            encode_window_progress.insert(END, '')
            app_progress_bar = ttk.Progressbar(window,
                                               orient=HORIZONTAL,
                                               mode='determinate')
            app_progress_bar.grid(row=2,
                                  columnspan=2,
                                  pady=(10, 10),
                                  padx=15,
                                  sticky=E + W)

            def my_hook(
                d
            ):  # This updates the progress bar with the correct percentage
                if d['status'] == 'downloading':
                    p = d['_percent_str']
                    p = p.replace('%', '')
                    app_progress_bar['value'] = float(p)

            class MyLogger:  # ytb-dl logger, allows the program to get all the needed info from the program
                global download_info_string

                def debug(self, msg):
                    # For compatability with youtube-dl, both debug and info are passed into debug
                    # You can distinguish them by the prefix '[debug] '
                    if msg.startswith('[debug] '):
                        pass
                    else:
                        self.info(msg)

                def info(self, msg):
                    encode_window_progress.delete('1.0', END)
                    encode_window_progress.insert(END, msg)

                def warning(self, msg):
                    pass

                def error(self, msg):
                    pass

            if video_only.get(
            ) == 'on':  # If "Best Video..." is selected then use these options for ytb-dl
                ydl_opts = {
                    'ratelimit': download_rate_choices[download_rate.get()],
                    'progress_hooks': [my_hook],
                    'noplaylist': True,
                    'overwrites': True,
                    'merge_output_format': 'mkv',
                    'final_ext': 'mkv',
                    'outtmpl':
                    str(pathlib.Path(VideoOutput)) + '/%(title)s.%(ext)s',
                    'ffmpeg_location': str(pathlib.Path(ffmpeg)),
                    'logger': MyLogger(),
                    "progress_with_newline": True,
                    'format':
                    video_menu_options_choices[video_menu_options.get()],
                    'prefer_ffmpeg': True
                }

            if video_only.get() != 'on' and audio_menu_options.get(
            ) == 'Extract Only':
                # If "Best Video..." is NOT selected and "Audio Menu" is set to Extract Only
                ydl_opts = {
                    'ratelimit': download_rate_choices[download_rate.get()],
                    'progress_hooks': [my_hook],
                    'noplaylist': True,
                    'overwrites': True,
                    'outtmpl':
                    str(pathlib.Path(VideoOutput)) + '/%(title)s.%(ext)s',
                    'ffmpeg_location': str(pathlib.Path(ffmpeg)),
                    'logger': MyLogger(),
                    "progress_with_newline": True,
                    'format': 'bestaudio/best',
                    'extractaudio': True,
                    'prefer_ffmpeg': True
                }

            if video_only.get() != 'on' and audio_menu_options.get(
            ) != 'Extract Only':
                # If "Best Video..." is NOT selected and "Audio Menu" is set to encode to another codec
                ydl_opts = {
                    'ratelimit':
                    download_rate_choices[download_rate.get()],
                    'progress_hooks': [my_hook],
                    'noplaylist':
                    True,
                    'overwrites':
                    True,
                    'outtmpl':
                    str(pathlib.Path(VideoOutput)) + '/%(title)s.%(ext)s',
                    'ffmpeg_location':
                    str(pathlib.Path(ffmpeg)),
                    'logger':
                    MyLogger(),
                    "progress_with_newline":
                    True,
                    'format':
                    'bestaudio/best',
                    'extractaudio':
                    True,
                    'prefer_ffmpeg':
                    True,
                    'postprocessors': [{
                        'key':
                        'FFmpegExtractAudio',
                        'preferredcodec':
                        audio_menu_options_choices[audio_menu_options.get()],
                        'preferredquality':
                        '0'
                    }]
                }

            with yt_dlp.YoutubeDL(
                    ydl_opts
            ) as ydl:  # Block of code needed to process the link/file
                ydl.download([download_link])

            window.destroy(
            )  # Once the job is complete this destroys the download/processing window

        # --------------------------------------------------------------------------------------------------- Start Job

        # Buttons and Entry Box's -------------------------------------------------------------------------------------
        text_area = scrolledtext.ScrolledText(link_frame,
                                              wrap=WORD,
                                              width=69,
                                              height=1,
                                              font=("Times New Roman", 14),
                                              foreground="grey")
        text_area.insert(END, "Right Click or 'Ctrl + V'")
        text_area.grid(row=0,
                       column=0,
                       columnspan=3,
                       pady=(1, 5),
                       padx=10,
                       sticky=W + E)

        # ------------------------------------------------------------------ Right click menu to paste in text_area box
        def paste_clipboard(
        ):  # Allows user to paste what ever is in their clipboard with right click and paste
            text_area.delete(1.0, END)
            text_area.config(foreground="black")
            text_area.insert(END, pyperclip.paste())

        def remove_text(
                e):  # Deletes current text in text box upon 'Left Clicking'
            text_area.config(foreground="black")
            text_area.delete(1.0, END)
            link_input_label.configure(
                text='Please Paste Link Above and Select "Add Link"')
            link_entry.config(state=NORMAL)  #
            link_entry.delete(
                0, END
            )  # This function clears entry box in order to add new link to entry box
            link_entry.config(state=DISABLED)  #

        m = Menu(main, tearoff=0)  # Pop up menu for 'Paste'
        m.add_command(label="Paste", command=paste_clipboard)

        def do_popup(
            event
        ):  # This code allows the program to know where the cursor is upon right clicking
            try:
                m.tk_popup(event.x_root, event.y_root)
            finally:
                m.grab_release()

        text_area.bind("<Button-3>",
                       do_popup)  # Uses right click to make a function
        text_area.bind("<Button-1>",
                       remove_text)  # Uses left click to make a function
        # Right click menu to paste in text_area box ------------------------------------------------------------------

        link_entry = Entry(link_frame,
                           borderwidth=4,
                           background="#CACACA",
                           state=DISABLED,
                           width=70)
        link_entry.grid(row=1,
                        column=1,
                        columnspan=2,
                        padx=10,
                        pady=(0, 0),
                        sticky=W + E)

        def apply_btn_hover(e):
            apply_btn["bg"] = "grey"

        def apply_btn_hover_leave(e):
            apply_btn["bg"] = "#8b0000"

        apply_btn = Button(link_frame,
                           text="Add Link",
                           command=apply_link,
                           foreground="white",
                           background="#8b0000",
                           width=30)
        apply_btn.grid(row=1,
                       column=0,
                       columnspan=1,
                       padx=10,
                       pady=5,
                       sticky=W)
        apply_btn.bind("<Enter>", apply_btn_hover)
        apply_btn.bind("<Leave>", apply_btn_hover_leave)

        def save_btn_hover(e):
            save_btn["bg"] = "grey"

        def save_btn_hover_leave(e):
            save_btn["bg"] = "#8b0000"

        save_btn = Button(main,
                          text="Save Directory",
                          command=file_save,
                          foreground="white",
                          background="#8b0000",
                          state=DISABLED)
        save_btn.grid(row=4,
                      column=0,
                      columnspan=1,
                      padx=10,
                      pady=(15, 0),
                      sticky=W + E)
        save_btn.bind("<Enter>", save_btn_hover)
        save_btn.bind("<Leave>", save_btn_hover_leave)

        save_entry = Entry(main,
                           borderwidth=4,
                           background="#CACACA",
                           state=DISABLED)
        save_entry.grid(row=4,
                        column=1,
                        columnspan=3,
                        padx=10,
                        pady=(15, 0),
                        sticky=W + E)

        def start_job_btn_hover(e):
            start_job_btn["bg"] = "grey"

        def start_job_btn_hover_leave(e):
            start_job_btn["bg"] = "#8b0000"

        start_job_btn = Button(
            main,
            text="Start Job",
            command=lambda: threading.Thread(target=start_job).start(),
            foreground="white",
            background="#8b0000",
            state=DISABLED)
        start_job_btn.grid(row=5,
                           column=3,
                           columnspan=1,
                           padx=10,
                           pady=(15, 15),
                           sticky=N + S + W + E)
        start_job_btn.bind("<Enter>", start_job_btn_hover)
        start_job_btn.bind("<Leave>", start_job_btn_hover_leave)

        # ------------------------------------------------------------------------------------- Buttons and Entry Box's

        # End Loop ----------------------------------------------------------------------------------------------------
        main.mainloop()
Exemple #12
0
class FilePickEdit(Frame):
    
    def __init__(self, master, file_mask, default_file, edit_height = None, user_onChange = None, 
                 rename_on_edit=0, font = None, coloring=True, allowNone=False, highlighter=None, directory='.'):
        """
            file_mask: file mask (e.g. "*.foo") or list of file masks (e.g. ["*.foo", "*.abl"])
        """
        self.master = master
        self.directory = directory
        self.user_onChange = user_onChange
        Frame.__init__(self, master)
        row = 0
        self.unmodified = True
        self.allowNone = allowNone
        self.file_extension = ""
        if type(file_mask) != list:
            file_mask = [file_mask]
        if "." in file_mask[0]:
            self.file_extension = file_mask[0][file_mask[0].rfind('.'):]
        # read filenames
        self.file_mask = file_mask
        self.updateList()
        # filename frame
        self.list_frame = Frame(self)
        self.list_frame.grid(row=row, column=0, sticky="WE")
        self.list_frame.columnconfigure(0, weight=1)
        # create list
        self.picked_name = StringVar()
        self.makelist()
        # refresh button
        self.refresh_button = Button(self.list_frame, text='<- refresh', command=self.refresh, height=1)
        self.refresh_button.grid(row=0, column=1, sticky='E')        
        # save button
        self.save_button = Button(self.list_frame, text="save", command=self.save, height=1)
        self.save_button.grid(row=0, column=2, sticky="E")
        # editor
        row += 1
        if coloring:
            self.editor = SyntaxHighlightingText(self, self.onEdit, highlighter=highlighter)
        else:
            self.editor = ScrolledText2(self, self.onEdit)
        if font is not None:
            self.editor.configure(font=font)
        if edit_height is not None:
            self.editor.configure(height=edit_height)
        self.editor.grid(row=row, column=0, sticky="NEWS")
        self.rowconfigure(row, weight=1)
        self.columnconfigure(0, weight=1)
        # option to change filename on edit
        row += 1
        self.options_frame = Frame(self)
        self.options_frame.grid(row=row, column=0, sticky=W)
        self.rename_on_edit = IntVar()
        self.cb = Checkbutton(self.options_frame, text="rename on edit", variable=self.rename_on_edit)
        self.cb.pack(side=LEFT)
        self.cb.configure(command=self.onChangeRename)
        self.rename_on_edit.set(rename_on_edit)
        # filename frame
        row += 1
        self.filename_frame = Frame(self)
        self.filename_frame.grid(row=row, column=0, sticky="WE")
        self.filename_frame.columnconfigure(0, weight=1)
        # save as filename
        self.save_name = StringVar()
        self.save_edit = Entry(self.filename_frame, textvariable = self.save_name)
        self.save_edit.grid(row=0, column=0, sticky="WE")
        self.save_name.trace("w", self.onSaveChange)
        # pick default if applicableButton
        self.select(default_file)
        self.row = row
        
    def setDirectory(self, directory, keep=False):
        self.directory = directory
        self.updateList()
        self.makelist()
#         menu = self.list["menu"] scrolledlist
#         menu = self.list.listbox#["scrolledlist"]
#         menu.delete(0, 'end')
        # add the new ones
#         for filename in self.files:
#             menu.add_command(label=filename, command=_setit(self.picked_name, filename, None))
        # if keep is true, only the files list will be updated but the content of the
        # text area will not be altered/removed
        if not keep: self.select("")
    
    def refresh(self):
        sel = self.get()
        self.updateList()
        self.select(sel, notify=False)
    
    def reloadFile(self):
        self.editor.delete("1.0", END)
        filename = self.picked_name.get()
        if os.path.exists(os.path.join(self.directory, filename)):
            new_text = open(os.path.join(self.directory, filename)).read()
            if new_text.strip() == "":
                new_text = "// %s is empty\n" % filename
            new_text = new_text.replace("\r", "")
        else:
            new_text = ""
        self.editor.insert(INSERT, new_text)
        
    def setText(self, txt):
        """
        Replaces the text in the edit field as by typing
        into it.
        """
        self.select("")
        if txt.strip() == "":
            txt = "// empty database\n"
        self.editor.insert(INSERT, txt)
        self.onEdit()
        

    def onSelChange(self):
        self.reloadFile()
        filename = self.picked_name.get()
        self.save_name.set(filename)
        self.save_edit.configure(state=DISABLED)
        self.unmodified = True
        if self.user_onChange is not None:
            self.user_onChange(filename)

    def onSaveChange(self, name, index, mode):
        pass

    def autoRename(self):
        # modify "save as" name
        filename = self.picked_name.get()
        if filename == "": filename = "new" + self.file_extension # if no file selected, create new filename
        ext = ""
        extpos = filename.rfind(".")
        if extpos != -1: ext = filename[extpos:]
        base = filename[:extpos]
        hpos = base.rfind("-")
        num = 0
        if hpos != -1:
            try:
                num = int(base[hpos+1:])
                base = base[:hpos]
            except:
                pass
        while True:
            num += 1
            filename = "%s-%d%s" % (base, num, ext)
            if not os.path.exists(filename):
                break
        self.save_name.set(filename)
        # user callback
        if self.user_onChange is not None:
            self.user_onChange(filename)

    def onEdit(self):
        if self.unmodified:
            self.unmodified = False
            # do auto rename if it's enabled or there is no file selected (editing new file)
            if self.rename_on_edit.get() == 1 or self.picked_name.get() == "":
                self.autoRename()
            # enable editing of save as name
            self.save_edit.configure(state=NORMAL)

    def onChangeRename(self):
        # called when clicking on "rename on edit" checkbox
        if self.rename_on_edit.get() == 1:
            if (not self.unmodified) and self.save_name.get() == self.picked_name.get():
                self.autoRename()
        else:
            self.save_name.set(self.picked_name.get())

    def updateList(self):
        self.files = []
        if self.allowNone:
            self.files.append("")
        if os.path.exists(self.directory):
            for filename in os.listdir(self.directory):
                for fm in self.file_mask:
                    if fnmatch(filename, fm):
                        self.files.append(filename)
        self.files.sort()
        if len(self.files) == 0 and not self.allowNone: self.files.append("(no %s files found)" % str(self.file_mask))
        

    def select(self, filename, notify=True):
        """ selects the item given by filename """
        if filename in self.files:
            if not havePMW:
                self.picked_name.set(filename)
            else:
                self.list.selectitem(self.files.index(filename))
                if notify: self.onSelChange(filename)
        else:
            self.editor.delete("1.0", END)
                

    def makelist(self):
        if havePMW:
            self.list = ComboBox(self.list_frame,
                    selectioncommand = self.onSelChange,
                    scrolledlist_items = self.files,
            )
            self.list.grid(row=0, column=0, padx=0, pady=0, sticky="NEWS")
            self.list.component('entryfield').component('entry').configure(state = 'readonly', relief = 'raised')
            self.picked_name = self.list
        else:
            self.list = OptionMenu(*(self.list_frame, self.picked_name) + tuple(self.files))
            self.list.grid(row=0, column=0, sticky="NEW")
            self.picked_name.trace("w", self.onSelChange)

    def save(self):
        self.get()

    def set(self, selected_item):
        self.select(selected_item)

    def get(self):
        """ gets the name of the currently selected file, saving it first if necessary """
        filename = self.save_name.get()
        if self.unmodified == False:
            self.unmodified = True
            # save the file
            f = open(os.path.join(self.directory, filename), "w")
            f.write(self.editor.get("1.0", END).encode('utf-8'))
            f.close()
            # add it to the list of files
#             if not filename in self.files:
#                 self.files.append(filename)
#                 self.files.sort()
#                 self.list.destroy()
#                 self.makelist()
            # set it as the new pick
            #if havePMW:
            #    self.picked_name.selectitem(self.files.index(filename), 1)
            #else:
            #    self.picked_name.set(filename)
#             self.select(filename)
            self.refresh()
            self.select(filename, notify=False)
            self.save_edit.configure(state=DISABLED)
        return filename

    def get_text(self):
        return self.editor.get("1.0", END)

    def get_filename(self):
        return self.save_name.get()

    def set_enabled(self, state):
        self.editor.configure(state=state)
        if havePMW:
            self.list.component('entryfield_entry').configure(state=state)
#             self.list.component('arrowbutton').configure(state=state)
            self.list.component('arrowbutton').bind('<1>', (lambda a: 'break') if state==DISABLED else self.list._postList)
        else:
            self.list.configure(state=state)
        self.save_button.configure(state=state)
        self.cb.configure(state=state)
        self.save_edit.configure(state=state)
Exemple #13
0
class LoginPage:

    user: str
    user_id: int
    hire: str
    isEmployer: int

    def __init__(
        self, login=Tk()
    ):  # This is my first change so i already initialize a Tk window inside the class
        """
        :type login: object
        """
        # self.user: str
        # self.user_id: int
        # self.hire: str
        # self.isEmployer: int
        self.__login = login
        self.__login.protocol("WM_DELETE_WINDOW", self.__event_x)
        self.__login.title("Login - Docházkový systém MANDINEC 1.0")
        self.__login.geometry("450x230+450+170")
        self.__init_ui()

    def __init_ui(self):
        """Create graphic interface
        """
        self.username = Label(self.__login, text="Username:"******"Password:"******"Login")
        self.login_button.place(relx=0.440, rely=0.638, height=30, width=60)
        self.login_button.configure(command=self.login_user)

        self.login_completed = IntVar()

        self.exit_button = Button(self.__login,
                                  text="Exit")  # , command=master.quit)
        self.exit_button.place(relx=0.614, rely=0.638, height=30, width=60)
        self.exit_button.configure(command=self.exit_login)

        self.username_box = Entry(self.__login)
        self.username_box.place(relx=0.440,
                                rely=0.298,
                                height=20,
                                relwidth=0.35)

        self.password_box = Entry(self.__login)
        self.password_box.place(relx=0.440,
                                rely=0.468,
                                height=20,
                                relwidth=0.35)
        self.password_box.configure(show="*")
        self.password_box.configure(background="white")

        self.var = IntVar()
        self.show_password = Checkbutton(self.__login)
        self.show_password.place(relx=0.285,
                                 rely=0.650,
                                 relheight=0.100,
                                 relwidth=0.125)
        self.show_password.configure(justify='left')
        self.show_password.configure(text='''Show''')
        self.show_password.configure(variable=self.var, command=self.__cb)

    def __event_x(self):
        if messagebox.askokcancel("Exit", "Are you sure you want to exit?"):
            exit()

    def __cb(self, ):
        if self.var.get():
            self.password_box.configure(show="")
        else:
            self.password_box.configure(show="*")

    # Giving function to login process

    def login_user(self):
        """Login user
        """
        name = self.username_box.get()
        password = self.password_box.get()
        # login_completed = self.login_completed.get()

        # AUTO DATA PRO TESTOVÁNÍ
        # name = "dom53"
        # password = "******"

        conn = db.create_connection()
        # us = db.select_user_by_id(conn, 1)
        # row = db.select_user_by_id(conn, 1)[0]
        # row = db.select_user_by_credentials(conn, name, password)[0]
        row: tuple
        try:
            row = db.select_user_by_credentials2(conn, name)[0]
            print("row")
            print(type(row))
        except IndexError:
            messagebox.showwarning("Login Failed - Access Denied",
                                   "Username or Password incorrect!")
            raise ValueError("Wrong credentials! - Access denied")

        # print("name: " + name)
        # print("password: "******"row[1]: " + row[1])
        # print("row[2]: " + row[2])

        # global qq
        # global userId
        # global hire
        # global isEmployer
        self.user = row[3] + " " + row[4]
        self.user_id = row[0]
        self.hire = row[5]
        self.isEmployer = row[7]
        # print("tady typy")
        # print(type(self.user))
        # print(type(self.user_id))
        # print(type(self.hire))
        # print(type(self.isEmployer))
        # print("isEmployer")
        # print(self.isEmployer)
        # print(password)
        # print(row[2])

        if name == row[1] and helper.Validation.verify_password(
                row[2], password):
            messagebox.showinfo("Login page", "Login successful!")
            self.__login.destroy()  # Removes the toplevel window
        else:
            messagebox.showwarning("Login Failed - Access Denied",
                                   "Username or Password incorrect!")

    @property
    def get_user_id(self) -> int:
        """Return user id
        Returns:
            user id
        """
        return self.user_id

    @property
    def get_user_name(self) -> str:
        """Return username
        Returns:
            username
        """
        print("no co")
        print(self.user)
        return self.user

    @property
    def get_hire_date(self) -> str:
        """Return hire date
        Returns:
            hire date
        """
        return self.hire

    @property
    def is_employer(self) -> int:
        """Return if user is employer
        Returns:
            True if user is employer otherwise False
        """
        return self.isEmployer

    # def hire_user(self):
    #     print("hire user")

    def exit_login(self):
        msg = messagebox.askyesno("Exit login page",
                                  "Do you really want to exit?")
        if msg:
            exit()

    def mainloop_window(self):
        """Function that helps me to mainloop the window
        """
        self.__login.mainloop()