Example #1
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'

        top.geometry("363x276+342+202")
        top.minsize(120, 1)
        top.maxsize(1370, 749)
        top.resizable(1, 1)
        top.title("LOGIN")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.Label1 = tk.Label(top)
        self.Label1.place(relx=0.405, rely=0.174, height=17, width=59)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Username''')

        self.Label2 = tk.Label(top)
        self.Label2.place(relx=0.413, rely=0.435, height=17, width=56)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#d9d9d9")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Password''')

        self.username = tk.Entry(top)
        self.username.place(relx=0.358, rely=0.254, height=20, relwidth=0.287)
        self.username.configure(background="white")
        self.username.configure(disabledforeground="#a3a3a3")
        self.username.configure(font="TkFixedFont")
        self.username.configure(foreground="#000000")
        self.username.configure(highlightbackground="#d9d9d9")
        self.username.configure(highlightcolor="black")
        self.username.configure(insertbackground="black")
        self.username.configure(selectbackground="#c4c4c4")
        self.username.configure(selectforeground="black")

        self.password = tk.Entry(top)
        self.password.place(relx=0.386, rely=0.543, height=20, relwidth=0.231)
        self.password.configure(background="white")
        self.password.configure(disabledforeground="#a3a3a3")
        self.password.configure(font="TkFixedFont")
        self.password.configure(foreground="#000000")
        self.password.configure(highlightbackground="#d9d9d9")
        self.password.configure(highlightcolor="black")
        self.password.configure(insertbackground="black")
        self.password.configure(selectbackground="#c4c4c4")
        self.password.configure(selectforeground="black")
        self.password.config(show="*")

        self.login = tk.Button(top)
        self.login.place(relx=0.441, rely=0.725, height=24, width=41)
        self.login.configure(activebackground="#ececec")
        self.login.configure(activeforeground="#000000")
        self.login.configure(background="#d9d9d9")
        self.login.configure(command=lambda: BaseView.login(
            self.username.get(), self.password.get()))
        self.login.configure(disabledforeground="#a3a3a3")
        self.login.configure(foreground="#000000")
        self.login.configure(highlightbackground="#d9d9d9")
        self.login.configure(highlightcolor="black")
        self.login.configure(pady="0")
        self.login.configure(text='''Login''')

        self.register = tk.Button(top)
        self.register.place(relx=0.826, rely=0.87, height=24, width=53)
        self.register.configure(activebackground="#ececec")
        self.register.configure(activeforeground="#000000")
        self.register.configure(background="#d9d9d9")
        self.register.configure(disabledforeground="#a3a3a3")
        self.register.configure(command=lambda: BaseView.redirect(Register))
        self.register.configure(foreground="#000000")
        self.register.configure(highlightbackground="#d9d9d9")
        self.register.configure(highlightcolor="black")
        self.register.configure(pady="0")
        self.register.configure(text='''Register''')

        self.menubar = tk.Menu(top,
                               font="TkMenuFont",
                               bg=_bgcolor,
                               fg=_fgcolor)
        top.configure(menu=self.menubar)
Example #2
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'

        top.geometry("984x714+523+107")
        top.minsize(148, 1)
        top.maxsize(1924, 1055)
        top.resizable(1, 1)
        top.title("New Toplevel")
        top.configure(background="#d9d9d9")

        self.Labelframe1 = tk.LabelFrame(top)
        self.Labelframe1.place(relx=0.022,
                               rely=0.011,
                               relheight=0.298,
                               relwidth=0.437)
        self.Labelframe1.configure(relief='groove')
        self.Labelframe1.configure(foreground="black")
        self.Labelframe1.configure(text='''Bedroom''')
        self.Labelframe1.configure(background="#d9d9d9")

        self.Label1 = tk.Label(self.Labelframe1)
        self.Label1.place(relx=0.023,
                          rely=0.131,
                          height=18,
                          width=42,
                          bordermode='ignore')
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(text='''Fan 1''')

        self.Label2 = tk.Label(self.Labelframe1)
        self.Label2.place(relx=0.023,
                          rely=0.263,
                          height=18,
                          width=42,
                          bordermode='ignore')
        self.Label2.configure(background="#d9d9d9")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(text='''Fan 2''')

        self.Label3 = tk.Label(self.Labelframe1)
        self.Label3.place(relx=0.023,
                          rely=0.399,
                          height=18,
                          width=81,
                          bordermode='ignore')
        self.Label3.configure(background="#d9d9d9")
        self.Label3.configure(disabledforeground="#a3a3a3")
        self.Label3.configure(foreground="#000000")
        self.Label3.configure(text='''Tubelight 1''')

        self.Label4 = tk.Label(self.Labelframe1)
        self.Label4.place(relx=0.023,
                          rely=0.531,
                          height=18,
                          width=81,
                          bordermode='ignore')
        self.Label4.configure(background="#d9d9d9")
        self.Label4.configure(disabledforeground="#a3a3a3")
        self.Label4.configure(foreground="#000000")
        self.Label4.configure(text='''Tubelight 2''')

        self.Label5 = tk.Label(self.Labelframe1)
        self.Label5.place(relx=0.023,
                          rely=0.662,
                          height=18,
                          width=102,
                          bordermode='ignore')
        self.Label5.configure(background="#d9d9d9")
        self.Label5.configure(disabledforeground="#a3a3a3")
        self.Label5.configure(foreground="#000000")
        self.Label5.configure(text='''Air Conditioner''')

        self.Label6 = tk.Label(self.Labelframe1)
        self.Label6.place(relx=0.023,
                          rely=0.798,
                          height=17,
                          width=142,
                          bordermode='ignore')
        self.Label6.configure(background="#d9d9d9")
        self.Label6.configure(disabledforeground="#a3a3a3")
        self.Label6.configure(foreground="#000000")
        self.Label6.configure(text='''Current Temperature:''')

        self.temp_indicator = tk.Label(self.Labelframe1)
        self.temp_indicator.place(relx=0.395,
                                  rely=0.793,
                                  height=19,
                                  width=102,
                                  bordermode='ignore')
        self.temp_indicator.configure(background="#d9d9d9")
        self.temp_indicator.configure(borderwidth="4")
        self.temp_indicator.configure(disabledforeground="#a3a3a3")
        self.temp_indicator.configure(foreground="#000000")
        self.temp_indicator.configure(textvariable=unknown_support.temp)

        self.Button1 = tk.Button(self.Labelframe1)
        self.Button1.place(relx=0.186,
                           rely=0.131,
                           height=23,
                           width=22,
                           bordermode='ignore')
        self.Button1.configure(activebackground="#37df0d")
        self.Button1.configure(activeforeground="#000000")
        self.Button1.configure(background="#ff0f0f")
        self.Button1.configure(disabledforeground="#a3a3a3")
        self.Button1.configure(foreground="#000000")
        self.Button1.configure(highlightbackground="#d9d9d9")
        self.Button1.configure(highlightcolor="black")
        self.Button1.configure(pady="0")

        self.Button1_4 = tk.Button(self.Labelframe1)
        self.Button1_4.place(relx=0.279,
                             rely=0.399,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_4.configure(activebackground="#37df0d")
        self.Button1_4.configure(activeforeground="#000000")
        self.Button1_4.configure(background="#ff0f0f")
        self.Button1_4.configure(disabledforeground="#a3a3a3")
        self.Button1_4.configure(foreground="#000000")
        self.Button1_4.configure(highlightbackground="#d9d9d9")
        self.Button1_4.configure(highlightcolor="black")
        self.Button1_4.configure(pady="0")

        self.Button1_5 = tk.Button(self.Labelframe1)
        self.Button1_5.place(relx=0.186,
                             rely=0.254,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_5.configure(activebackground="#37df0d")
        self.Button1_5.configure(activeforeground="#000000")
        self.Button1_5.configure(background="#ff0f0f")
        self.Button1_5.configure(disabledforeground="#a3a3a3")
        self.Button1_5.configure(foreground="#000000")
        self.Button1_5.configure(highlightbackground="#d9d9d9")
        self.Button1_5.configure(highlightcolor="black")
        self.Button1_5.configure(pady="0")

        self.Button1_6 = tk.Button(self.Labelframe1)
        self.Button1_6.place(relx=0.279,
                             rely=0.54,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_6.configure(activebackground="#37df0d")
        self.Button1_6.configure(activeforeground="#000000")
        self.Button1_6.configure(background="#ff0f0f")
        self.Button1_6.configure(disabledforeground="#a3a3a3")
        self.Button1_6.configure(foreground="#000000")
        self.Button1_6.configure(highlightbackground="#d9d9d9")
        self.Button1_6.configure(highlightcolor="black")
        self.Button1_6.configure(pady="0")

        self.Button1_6 = tk.Button(self.Labelframe1)
        self.Button1_6.place(relx=0.349,
                             rely=0.648,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_6.configure(activebackground="#37df0d")
        self.Button1_6.configure(activeforeground="#000000")
        self.Button1_6.configure(background="#ff0f0f")
        self.Button1_6.configure(disabledforeground="#a3a3a3")
        self.Button1_6.configure(foreground="#000000")
        self.Button1_6.configure(highlightbackground="#d9d9d9")
        self.Button1_6.configure(highlightcolor="black")
        self.Button1_6.configure(pady="0")

        self.Labelframe1_8 = tk.LabelFrame(top)
        self.Labelframe1_8.place(relx=0.478,
                                 rely=0.013,
                                 relheight=0.203,
                                 relwidth=0.437)
        self.Labelframe1_8.configure(relief='groove')
        self.Labelframe1_8.configure(foreground="black")
        self.Labelframe1_8.configure(text='''Kitchen''')
        self.Labelframe1_8.configure(background="#d9d9d9")
        self.Labelframe1_8.configure(cursor="fleur")
        self.Labelframe1_8.configure(highlightbackground="#d9d9d9")
        self.Labelframe1_8.configure(highlightcolor="black")

        self.Label1_9 = tk.Label(self.Labelframe1_8)
        self.Label1_9.place(relx=0.023,
                            rely=0.138,
                            height=28,
                            width=42,
                            bordermode='ignore')
        self.Label1_9.configure(activebackground="#f9f9f9")
        self.Label1_9.configure(activeforeground="black")
        self.Label1_9.configure(background="#d9d9d9")
        self.Label1_9.configure(disabledforeground="#a3a3a3")
        self.Label1_9.configure(foreground="#000000")
        self.Label1_9.configure(highlightbackground="#d9d9d9")
        self.Label1_9.configure(highlightcolor="black")
        self.Label1_9.configure(text='''Fan 1''')

        self.Label3_11 = tk.Label(self.Labelframe1_8)
        self.Label3_11.place(relx=0.023,
                             rely=0.407,
                             height=29,
                             width=81,
                             bordermode='ignore')
        self.Label3_11.configure(activebackground="#f9f9f9")
        self.Label3_11.configure(activeforeground="black")
        self.Label3_11.configure(background="#d9d9d9")
        self.Label3_11.configure(disabledforeground="#a3a3a3")
        self.Label3_11.configure(foreground="#000000")
        self.Label3_11.configure(highlightbackground="#d9d9d9")
        self.Label3_11.configure(highlightcolor="black")
        self.Label3_11.configure(text='''Tubelight 1''')

        self.Label5_13 = tk.Label(self.Labelframe1_8)
        self.Label5_13.place(relx=0.023,
                             rely=0.759,
                             height=12,
                             width=112,
                             bordermode='ignore')
        self.Label5_13.configure(activebackground="#f9f9f9")
        self.Label5_13.configure(activeforeground="black")
        self.Label5_13.configure(background="#d9d9d9")
        self.Label5_13.configure(disabledforeground="#a3a3a3")
        self.Label5_13.configure(foreground="#000000")
        self.Label5_13.configure(highlightbackground="#d9d9d9")
        self.Label5_13.configure(highlightcolor="black")
        self.Label5_13.configure(text='''Induction Stove''')

        self.Button1_16 = tk.Button(self.Labelframe1_8)
        self.Button1_16.place(relx=0.186,
                              rely=0.172,
                              height=23,
                              width=22,
                              bordermode='ignore')
        self.Button1_16.configure(activebackground="#37df0d")
        self.Button1_16.configure(activeforeground="#000000")
        self.Button1_16.configure(background="#ff0f0f")
        self.Button1_16.configure(cursor="fleur")
        self.Button1_16.configure(disabledforeground="#a3a3a3")
        self.Button1_16.configure(foreground="#000000")
        self.Button1_16.configure(highlightbackground="#d9d9d9")
        self.Button1_16.configure(highlightcolor="black")
        self.Button1_16.configure(pady="0")

        self.Button1_5 = tk.Button(self.Labelframe1_8)
        self.Button1_5.place(relx=0.302,
                             rely=0.407,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_5.configure(activebackground="#37df0d")
        self.Button1_5.configure(activeforeground="#000000")
        self.Button1_5.configure(background="#ff0f0f")
        self.Button1_5.configure(disabledforeground="#a3a3a3")
        self.Button1_5.configure(foreground="#000000")
        self.Button1_5.configure(highlightbackground="#d9d9d9")
        self.Button1_5.configure(highlightcolor="black")
        self.Button1_5.configure(pady="0")

        self.Button1_7 = tk.Button(self.Labelframe1_8)
        self.Button1_7.place(relx=0.372,
                             rely=0.703,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_7.configure(activebackground="#37df0d")
        self.Button1_7.configure(activeforeground="#000000")
        self.Button1_7.configure(background="#ff0f0f")
        self.Button1_7.configure(disabledforeground="#a3a3a3")
        self.Button1_7.configure(foreground="#000000")
        self.Button1_7.configure(highlightbackground="#d9d9d9")
        self.Button1_7.configure(highlightcolor="black")
        self.Button1_7.configure(pady="0")

        self.Labelframe1_8 = tk.LabelFrame(top)
        self.Labelframe1_8.place(relx=0.02,
                                 rely=0.324,
                                 relheight=0.276,
                                 relwidth=0.437)
        self.Labelframe1_8.configure(relief='groove')
        self.Labelframe1_8.configure(foreground="black")
        self.Labelframe1_8.configure(text='''Dining Room''')
        self.Labelframe1_8.configure(background="#d9d9d9")
        self.Labelframe1_8.configure(highlightbackground="#d9d9d9")
        self.Labelframe1_8.configure(highlightcolor="black")

        self.Label1_9 = tk.Label(self.Labelframe1_8)
        self.Label1_9.place(relx=0.023,
                            rely=0.132,
                            height=17,
                            width=42,
                            bordermode='ignore')
        self.Label1_9.configure(activebackground="#f9f9f9")
        self.Label1_9.configure(activeforeground="black")
        self.Label1_9.configure(background="#d9d9d9")
        self.Label1_9.configure(disabledforeground="#a3a3a3")
        self.Label1_9.configure(foreground="#000000")
        self.Label1_9.configure(highlightbackground="#d9d9d9")
        self.Label1_9.configure(highlightcolor="black")
        self.Label1_9.configure(text='''Fan 1''')

        self.Label2_10 = tk.Label(self.Labelframe1_8)
        self.Label2_10.place(relx=0.023,
                             rely=0.264,
                             height=17,
                             width=42,
                             bordermode='ignore')
        self.Label2_10.configure(activebackground="#f9f9f9")
        self.Label2_10.configure(activeforeground="black")
        self.Label2_10.configure(background="#d9d9d9")
        self.Label2_10.configure(disabledforeground="#a3a3a3")
        self.Label2_10.configure(foreground="#000000")
        self.Label2_10.configure(highlightbackground="#d9d9d9")
        self.Label2_10.configure(highlightcolor="black")
        self.Label2_10.configure(text='''Fan 2''')

        self.Label3_11 = tk.Label(self.Labelframe1_8)
        self.Label3_11.place(relx=0.023,
                             rely=0.396,
                             height=17,
                             width=81,
                             bordermode='ignore')
        self.Label3_11.configure(activebackground="#f9f9f9")
        self.Label3_11.configure(activeforeground="black")
        self.Label3_11.configure(background="#d9d9d9")
        self.Label3_11.configure(disabledforeground="#a3a3a3")
        self.Label3_11.configure(foreground="#000000")
        self.Label3_11.configure(highlightbackground="#d9d9d9")
        self.Label3_11.configure(highlightcolor="black")
        self.Label3_11.configure(text='''Tubelight 1''')

        self.Label4_12 = tk.Label(self.Labelframe1_8)
        self.Label4_12.place(relx=0.023,
                             rely=0.533,
                             height=16,
                             width=81,
                             bordermode='ignore')
        self.Label4_12.configure(activebackground="#f9f9f9")
        self.Label4_12.configure(activeforeground="black")
        self.Label4_12.configure(background="#d9d9d9")
        self.Label4_12.configure(disabledforeground="#a3a3a3")
        self.Label4_12.configure(foreground="#000000")
        self.Label4_12.configure(highlightbackground="#d9d9d9")
        self.Label4_12.configure(highlightcolor="black")
        self.Label4_12.configure(text='''Tubelight 2''')

        self.Label5_13 = tk.Label(self.Labelframe1_8)
        self.Label5_13.place(relx=0.023,
                             rely=0.665,
                             height=17,
                             width=72,
                             bordermode='ignore')
        self.Label5_13.configure(activebackground="#f9f9f9")
        self.Label5_13.configure(activeforeground="black")
        self.Label5_13.configure(background="#d9d9d9")
        self.Label5_13.configure(disabledforeground="#a3a3a3")
        self.Label5_13.configure(foreground="#000000")
        self.Label5_13.configure(highlightbackground="#d9d9d9")
        self.Label5_13.configure(highlightcolor="black")
        self.Label5_13.configure(text='''Television''')

        self.Button1_16 = tk.Button(self.Labelframe1_8)
        self.Button1_16.place(relx=0.186,
                              rely=0.132,
                              height=23,
                              width=22,
                              bordermode='ignore')
        self.Button1_16.configure(activebackground="#37df0d")
        self.Button1_16.configure(activeforeground="#000000")
        self.Button1_16.configure(background="#ff0f0f")
        self.Button1_16.configure(disabledforeground="#a3a3a3")
        self.Button1_16.configure(foreground="#000000")
        self.Button1_16.configure(highlightbackground="#d9d9d9")
        self.Button1_16.configure(highlightcolor="black")
        self.Button1_16.configure(pady="0")

        self.Button1_5 = tk.Button(self.Labelframe1_8)
        self.Button1_5.place(relx=0.279,
                             rely=0.401,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_5.configure(activebackground="#37df0d")
        self.Button1_5.configure(activeforeground="#000000")
        self.Button1_5.configure(background="#ff0f0f")
        self.Button1_5.configure(disabledforeground="#a3a3a3")
        self.Button1_5.configure(foreground="#000000")
        self.Button1_5.configure(highlightbackground="#d9d9d9")
        self.Button1_5.configure(highlightcolor="black")
        self.Button1_5.configure(pady="0")

        self.Button1_6 = tk.Button(self.Labelframe1_8)
        self.Button1_6.place(relx=0.186,
                             rely=0.254,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_6.configure(activebackground="#37df0d")
        self.Button1_6.configure(activeforeground="#000000")
        self.Button1_6.configure(background="#ff0f0f")
        self.Button1_6.configure(disabledforeground="#a3a3a3")
        self.Button1_6.configure(foreground="#000000")
        self.Button1_6.configure(highlightbackground="#d9d9d9")
        self.Button1_6.configure(highlightcolor="black")
        self.Button1_6.configure(pady="0")

        self.Button1_7 = tk.Button(self.Labelframe1_8)
        self.Button1_7.place(relx=0.279,
                             rely=0.543,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_7.configure(activebackground="#37df0d")
        self.Button1_7.configure(activeforeground="#000000")
        self.Button1_7.configure(background="#ff0f0f")
        self.Button1_7.configure(disabledforeground="#a3a3a3")
        self.Button1_7.configure(foreground="#000000")
        self.Button1_7.configure(highlightbackground="#d9d9d9")
        self.Button1_7.configure(highlightcolor="black")
        self.Button1_7.configure(pady="0")

        self.Button1_7 = tk.Button(self.Labelframe1_8)
        self.Button1_7.place(relx=0.233,
                             rely=0.675,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_7.configure(activebackground="#37df0d")
        self.Button1_7.configure(activeforeground="#000000")
        self.Button1_7.configure(background="#ff0f0f")
        self.Button1_7.configure(disabledforeground="#a3a3a3")
        self.Button1_7.configure(foreground="#000000")
        self.Button1_7.configure(highlightbackground="#d9d9d9")
        self.Button1_7.configure(highlightcolor="black")
        self.Button1_7.configure(pady="0")

        self.Labelframe1_9 = tk.LabelFrame(top)
        self.Labelframe1_9.place(relx=0.478,
                                 rely=0.227,
                                 relheight=0.204,
                                 relwidth=0.437)
        self.Labelframe1_9.configure(relief='groove')
        self.Labelframe1_9.configure(foreground="black")
        self.Labelframe1_9.configure(text='''Washroom''')
        self.Labelframe1_9.configure(background="#d9d9d9")
        self.Labelframe1_9.configure(highlightbackground="#d9d9d9")
        self.Labelframe1_9.configure(highlightcolor="black")

        self.Label1_10 = tk.Label(self.Labelframe1_9)
        self.Label1_10.place(relx=0.023,
                             rely=0.116,
                             height=29,
                             width=92,
                             bordermode='ignore')
        self.Label1_10.configure(activebackground="#f9f9f9")
        self.Label1_10.configure(activeforeground="black")
        self.Label1_10.configure(background="#d9d9d9")
        self.Label1_10.configure(disabledforeground="#a3a3a3")
        self.Label1_10.configure(foreground="#000000")
        self.Label1_10.configure(highlightbackground="#d9d9d9")
        self.Label1_10.configure(highlightcolor="black")
        self.Label1_10.configure(text='''Water Geyser''')

        self.Label3_12 = tk.Label(self.Labelframe1_9)
        self.Label3_12.place(relx=0.023,
                             rely=0.411,
                             height=29,
                             width=41,
                             bordermode='ignore')
        self.Label3_12.configure(activebackground="#f9f9f9")
        self.Label3_12.configure(activeforeground="black")
        self.Label3_12.configure(background="#d9d9d9")
        self.Label3_12.configure(disabledforeground="#a3a3a3")
        self.Label3_12.configure(foreground="#000000")
        self.Label3_12.configure(highlightbackground="#d9d9d9")
        self.Label3_12.configure(highlightcolor="black")
        self.Label3_12.configure(text='''Light''')

        self.Label5_14 = tk.Label(self.Labelframe1_9)
        self.Label5_14.place(relx=0.023,
                             rely=0.699,
                             height=21,
                             width=112,
                             bordermode='ignore')
        self.Label5_14.configure(activebackground="#f9f9f9")
        self.Label5_14.configure(activeforeground="black")
        self.Label5_14.configure(background="#d9d9d9")
        self.Label5_14.configure(cursor="fleur")
        self.Label5_14.configure(disabledforeground="#a3a3a3")
        self.Label5_14.configure(foreground="#000000")
        self.Label5_14.configure(highlightbackground="#d9d9d9")
        self.Label5_14.configure(highlightcolor="black")
        self.Label5_14.configure(text='''Water Tank Level''')

        self.Button1_15 = tk.Button(self.Labelframe1_9)
        self.Button1_15.place(relx=0.302,
                              rely=0.178,
                              height=23,
                              width=22,
                              bordermode='ignore')
        self.Button1_15.configure(activebackground="#37df0d")
        self.Button1_15.configure(activeforeground="#000000")
        self.Button1_15.configure(background="#ff0f0f")
        self.Button1_15.configure(disabledforeground="#a3a3a3")
        self.Button1_15.configure(foreground="#000000")
        self.Button1_15.configure(highlightbackground="#d9d9d9")
        self.Button1_15.configure(highlightcolor="black")
        self.Button1_15.configure(pady="0")

        self.Button1_6 = tk.Button(self.Labelframe1_9)
        self.Button1_6.place(relx=0.186,
                             rely=0.411,
                             height=23,
                             width=22,
                             bordermode='ignore')
        self.Button1_6.configure(activebackground="#37df0d")
        self.Button1_6.configure(activeforeground="#000000")
        self.Button1_6.configure(background="#ff0f0f")
        self.Button1_6.configure(disabledforeground="#a3a3a3")
        self.Button1_6.configure(foreground="#000000")
        self.Button1_6.configure(highlightbackground="#d9d9d9")
        self.Button1_6.configure(highlightcolor="black")
        self.Button1_6.configure(pady="0")

        self.Water_level = tk.Label(self.Labelframe1_9)
        self.Water_level.place(relx=0.349,
                               rely=0.699,
                               height=18,
                               width=102,
                               bordermode='ignore')
        self.Water_level.configure(activebackground="#f9f9f9")
        self.Water_level.configure(activeforeground="black")
        self.Water_level.configure(background="#d9d9d9")
        self.Water_level.configure(borderwidth="4")
        self.Water_level.configure(disabledforeground="#a3a3a3")
        self.Water_level.configure(foreground="#000000")
        self.Water_level.configure(highlightbackground="#d9d9d9")
        self.Water_level.configure(highlightcolor="black")
        self.Water_level.configure(textvariable=unknown_support.temp)
Example #3
0
    def __init__(self, root):

        style = StyleColors()
        style.ocean_style(
        )  # Select a style for the StyleColors class  Note: should proabably match the ItemView selection below

        top_frame_color = style.topFrameColor
        frame_color = style.frameColor
        highlight_color = style.highlightColor
        entry_highlight = style.entryHighlight
        entry_color = style.entryColor
        arrow_button = style.arrowButton
        arrow_bg = style.arrowBg
        bits_text_color = style.bitsTextColor
        bits_left_color = style.bitsLeftColor

        Tkinter.Frame.__init__(self, master=root, background=top_frame_color)

        self.model = None
        self.controller = None

        top_frame = Tkinter.Frame(self, background=frame_color)

        top_frame.configure()
        top_frame.pack(side=Tkinter.TOP,
                       anchor=Tkinter.N,
                       fill=Tkinter.X,
                       pady=(0, 15))
        # Menu Bar
        menuBar = Pmw.MenuBar(top_frame,
                              hull_relief=Tkinter.RIDGE,
                              hull_borderwidth=0,
                              padx=(10, 0),
                              hull_background=frame_color)
        menuBar.pack(side=Tkinter.LEFT,
                     anchor=Tkinter.NW,
                     expand=1,
                     fill=Tkinter.X)
        menuBar.addmenu('File', None, background=frame_color)
        menuBar.addmenuitem('File',
                            'command',
                            font=('StingerLight', 14),
                            label="Load...",
                            command=self.load_session)
        menuBar.addmenuitem('File',
                            'command',
                            font=('StingerLight', 14),
                            label="Validate..",
                            command=self.validate_session)
        menuBar.addmenuitem('File',
                            'command',
                            font=('StingerLight', 14),
                            label='Save As..',
                            command=self.save_session)

        self.__used_label = Tkinter.Label(top_frame)
        self.__used_label.pack(side=Tkinter.RIGHT, anchor=Tkinter.NE)
        self.__used_label.configure(background=bits_left_color,
                                    foreground=bits_text_color)
        self.__avail_label = Tkinter.Label(top_frame)
        self.__avail_label.pack(side=Tkinter.RIGHT, anchor=Tkinter.NE)
        self.__avail_label.configure(background=bits_left_color,
                                     foreground=bits_text_color)

        ## Session View
        session_select_frame = Tkinter.LabelFrame(self,
                                                  text="Session",
                                                  background=frame_color)
        session_select_frame.pack(side=Tkinter.TOP,
                                  anchor=Tkinter.N,
                                  fill=Tkinter.X,
                                  pady=(0, 15),
                                  padx=(10, 10))

        self.__new_packet_button = Tkinter.Button(
            session_select_frame,
            text="New Packet",
            highlightbackground=frame_color,
            command=self.__new_packet)
        self.__new_packet_button.pack(side=Tkinter.LEFT, padx=(20, 0))

        self.__select_packet_dd = Pmw.ComboBox(
            session_select_frame,
            labelpos='w',
            label_text='Packet:',
            label_background=frame_color,
            entry_background=frame_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            selectioncommand=self.__packet_selected)
        self.__select_packet_dd.component('entry').config(
            background=entry_color)
        self.__select_packet_dd.component('arrowbutton').configure(
            background=arrow_button, highlightbackground=arrow_bg)
        self.__select_packet_dd.pack(side=Tkinter.LEFT,
                                     anchor=Tkinter.NW,
                                     padx=(20, 20))
        self.__delete_packet_button = Tkinter.Button(
            session_select_frame,
            text="Delete Packet",
            highlightbackground=frame_color,
            command=self.__delete_packet)
        self.__delete_packet_button.pack(side=Tkinter.LEFT, anchor=Tkinter.NW)

        self.__duration_label = Tkinter.Label(
            session_select_frame, text="", background=frame_color
        )  #note: text is set in the config_session method
        self.__duration_label.pack(side=Tkinter.LEFT,
                                   anchor=Tkinter.SE,
                                   padx=(80, 0),
                                   pady=(0, 4))

        self.__tlm_rate_label = Tkinter.Label(
            session_select_frame, text="", background=frame_color
        )  #note: text is set in the config_session method
        self.__tlm_rate_label.pack(side=Tkinter.LEFT,
                                   anchor=Tkinter.SE,
                                   padx=(10, 0),
                                   pady=(0, 4))

        ## Packet Edit Frame
        packet_edit_frame = Tkinter.LabelFrame(self,
                                               text='Packet Attributes',
                                               background=frame_color)

        packet_edit_frame.pack(side=Tkinter.TOP,
                               anchor=Tkinter.N,
                               fill=Tkinter.X,
                               pady=(5, 20),
                               padx=(10, 10))

        self.__packet_id_entry = Pmw.EntryField(
            packet_edit_frame,
            labelpos='w',
            label_text='Packet ID:',
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            validate={
                'validator': 'numeric',
                'min': 0,
                'max': 65535,
                'minstrict': 0,
                'maxstrict': 1
            })
        self.__packet_id_entry.grid(row=0, column=0, sticky=Tkinter.E)

        self.__select_freq = Pmw.ComboBox(
            packet_edit_frame,
            labelpos='w',
            label_text=" Frequency:",
            entry_width=16,
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            entryfield_entry_state='readonly',
            selectioncommand=self.__freq_selected)
        self.__select_freq.component('entry').config(
            readonlybackground=entry_color)
        self.__select_freq.component('arrowbutton').configure(
            background=arrow_button, highlightbackground=arrow_bg)
        self.__select_freq.grid(row=0, column=1, sticky=Tkinter.E)

        self.__select_offset = Pmw.ComboBox(
            packet_edit_frame,
            labelpos='w',
            label_text='Offset:',
            entry_width=16,
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            entryfield_entry_state='readonly',
            selectioncommand=self.__offset_selected)
        self.__select_offset.component('entry').config(
            readonlybackground=entry_color)
        self.__select_offset.component('arrowbutton').configure(
            background=arrow_button, highlightbackground=arrow_bg)
        self.__select_offset.grid(row=0, column=2, sticky=Tkinter.E)

        self.__packet_name_entry = Pmw.EntryField(
            packet_edit_frame,
            labelpos='w',
            label_text='Packet Name:',
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight)
        self.__packet_name_entry.grid(row=1, column=0, sticky=Tkinter.E)

        self.__ff3_channel_entry = Pmw.EntryField(
            packet_edit_frame,
            labelpos='w',
            label_text='FF3 Channel:',
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            validate={
                'validator': 'numeric',
                'min': 0,
                'max': 65535,
                'minstrict': 0,
                'maxstrict': 1
            })
        self.__ff3_channel_entry.grid(row=1, column=1, sticky=Tkinter.E)

        self.__packet_save_button = Tkinter.Button(
            packet_edit_frame,
            text="Save Packet",
            highlightbackground=frame_color,
            command=self.__save_packet)
        self.__packet_save_button.grid(row=2,
                                       column=0,
                                       sticky=Tkinter.W,
                                       padx=(121, 0))

        ## Item Edit Frame
        item_edit_frame = Tkinter.LabelFrame(self,
                                             text='Items',
                                             background=frame_color)

        item_edit_frame.pack(side=Tkinter.TOP,
                             anchor=Tkinter.N,
                             fill=Tkinter.X,
                             pady=(0, 15),
                             padx=(10, 10))

        self.__select_comp_dd = Pmw.ComboBox(
            item_edit_frame,
            labelpos='w',
            label_text="Component:",
            entry_width=22,
            label_background=frame_color,
            entry_background=frame_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            entryfield_entry_state='readonly',
            selectioncommand=self.__comp_selected)
        self.__select_comp_dd.component('entry').config(
            readonlybackground=entry_color)
        self.__select_comp_dd.component('arrowbutton').configure(
            background=arrow_button, highlightbackground=arrow_bg)
        self.__select_comp_dd.grid(row=0,
                                   column=0,
                                   columnspan=1,
                                   sticky=Tkinter.E,
                                   padx=(16, 0))

        self.__select_channel_dd = Pmw.ComboBox(
            item_edit_frame,
            labelpos='w',
            label_text='Channel:',
            label_background=frame_color,
            entry_background=frame_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight,
            entryfield_entry_state='readonly',
            selectioncommand=self.__channel_selected)
        self.__select_channel_dd.component('entry').config(
            readonlybackground=entry_color)
        self.__select_channel_dd.component('arrowbutton').configure(
            background=arrow_button, highlightbackground=arrow_bg)

        self.__select_channel_dd.grid(row=0,
                                      column=1,
                                      columnspan=3,
                                      sticky=Tkinter.EW,
                                      padx=(9, 5))

        self.__size_entry = Pmw.EntryField(
            item_edit_frame,
            labelpos='w',
            entry_width=30,
            label_text='Size (bits):',
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight)
        self.__size_entry.grid(row=1,
                               column=1,
                               columnspan=1,
                               sticky=Tkinter.W,
                               padx=(0, 0))

        self.__add_reserve_button = Tkinter.Button(
            item_edit_frame,
            text="Add Reserve",
            highlightbackground=frame_color,
            command=self.__add_reserve)
        self.__add_reserve_button.grid(row=1,
                                       column=2,
                                       columnspan=1,
                                       sticky=Tkinter.E,
                                       padx=(20, 0))
        self.__reserve_entry = Pmw.EntryField(
            item_edit_frame,
            labelpos='w',
            entry_width=5,
            label_text='Bits:',
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight)
        self.__reserve_entry.grid(row=1,
                                  column=3,
                                  columnspan=1,
                                  sticky=Tkinter.W,
                                  padx=(0, 38))

        self.__desc_entry = Pmw.EntryField(
            item_edit_frame,
            labelpos='w',
            entry_width=30,
            label_text='Desc:',
            label_background=frame_color,
            entry_background=entry_color,
            hull_background=frame_color,
            label_highlightbackground=highlight_color,
            entry_highlightbackground=entry_highlight)
        self.__desc_entry.grid(row=2,
                               column=1,
                               columnspan=1,
                               sticky=Tkinter.W,
                               padx=(30, 0))

        self.__byte_align_button = Tkinter.Button(
            item_edit_frame,
            text="Byte Align    ",
            highlightbackground=frame_color,
            command=self.__byte_align)
        self.__byte_align_button.grid(row=2,
                                      column=2,
                                      columnspan=1,
                                      sticky=Tkinter.EW,
                                      padx=(20, 0))

        self.__add_item_button = Tkinter.Button(
            item_edit_frame,
            text='Add    ',
            highlightbackground=frame_color,
            command=self.__add_item)
        self.__add_item_button.grid(row=3,
                                    column=1,
                                    columnspan=1,
                                    sticky=Tkinter.W,
                                    padx=(72, 0))

        self.__word_align_button = Tkinter.Button(
            item_edit_frame,
            text="Word Align  ",
            highlightbackground=frame_color,
            command=self.__word_align)
        self.__word_align_button.grid(row=3,
                                      column=2,
                                      columnspan=1,
                                      sticky=Tkinter.EW,
                                      padx=(20, 0))

        self.__delete_item_button = Tkinter.Button(
            item_edit_frame,
            text="Delete",
            highlightbackground=frame_color,
            command=self.__delete_row)
        self.__delete_item_button.grid(row=4,
                                       column=1,
                                       columnspan=1,
                                       sticky=Tkinter.W,
                                       padx=(72, 0))

        # Configure editor frame grid
        for i in range(5):
            packet_edit_frame.grid_columnconfigure(i, weight=1)
            packet_edit_frame.grid_rowconfigure(i, weight=1)
            item_edit_frame.grid_columnconfigure(i, weight=1)
            item_edit_frame.grid_rowconfigure(i, weight=1)

        ## List Frame
        self.__item_list = ItemList(self)
        self.__item_list.pack(side=Tkinter.TOP,
                              anchor=Tkinter.N,
                              expand=1,
                              fill=Tkinter.BOTH)
Example #4
0
    def __init__(self, robot_initialPos):
        self.subscriber = None  # we need to have the subscriber as an object so we can unregister/register when paused/resumed

        self.resumedRun = False  # flag to determine if it is the first run after pressing 'resume'
        self.paused = True  # flag to determine if program is paused
        self.executing = False  # flag to determine if we are currently executing a plan

        self.prev_desiredPos = geometry_msgs.msg.Pose(
        ).position  # keep track of what the previous passed position was
        self.robot_zeroPos = geometry_msgs.msg.Pose(
        ).position  # keep track of the robot zero position
        self.hand_zeroPos = geometry_msgs.msg.Pose(
        ).position  # keep track of the hand zero position
        self.robot_initialPos = robot_initialPos  # keep track of the robot starting position

        self.enableDiffCheck = True  # If enabled will check for difference against a set max before allowing a move
        self.enableBoundaryCheck = True  # If enabled will check if robot is exceeding a boundary

        # boundaries | initial coords: x: 0.603 y: 0.124 z: 0.566
        self.maxLeft = self.robot_initialPos.x - 0.200  # x left
        self.maxRight = self.robot_initialPos.x + 0.200  # x right
        self.maxHeight = self.robot_initialPos.y + 0.300  # y height
        self.maxUp = self.robot_initialPos.z + 0.100  # z up
        self.maxDown = self.robot_initialPos.z - 0.100  # z down

        # maximum step, user cannot move more than this in one step
        self.maxStep = 0.150

        # this is used to round co-ordinates when checking if previous and current coords are very similar
        self.dp = 3  # decimal points
        '''
        -----------------------------------------
            gui_mainWindow
        -----------------------------------------
        '''

        # main GUI window
        self.gui_mainWindow = tk.Tk()
        self.gui_mainWindow.title("LM-Move | Control Panel")
        self.gui_mainWindow.geometry("350x210")
        self.gui_mainWindow.grid_rowconfigure(0, weight=1)
        self.gui_mainWindow.grid_columnconfigure(0, weight=1)
        self.gui_mainWindow.resizable(False, False)

        # current position label
        self.currentPosText = tk.StringVar()
        self.currentPosLabel = tk.Label(self.gui_mainWindow,
                                        textvariable=self.currentPosText).grid(
                                            row=0, column=0)
        self.currentPosText.set("Current Position\n\nNone!\n")

        # pause button
        self.pauseButtonText = tk.StringVar()
        self.pauseButton = tk.Button(self.gui_mainWindow,
                                     textvariable=self.pauseButtonText,
                                     command=self.trackingControl,
                                     width=20)
        self.pauseButtonText.set("Resume")
        self.pauseButton.configure(bg="green")
        self.pauseButton.grid(row=1, column=0)

        # toggle window button
        self.toggleInfoButton = tk.Button(self.gui_mainWindow,
                                          text="Positional Info",
                                          command=self.toggleInfoWindow,
                                          width=20).grid(row=2, column=0)

        # checkboxes
        self.checkStepBoolVar = tk.BooleanVar()
        self.checkStepBox = Checkbutton(self.gui_mainWindow,
                                        text="Robot Overstep Check",
                                        variable=self.checkStepBoolVar,
                                        width=20,
                                        anchor='w')
        self.checkStepBox.select()  # check by default
        self.checkStepBox.grid(row=3, column=0)

        self.checkBoundaryBoolVar = tk.BooleanVar()
        self.checkBoundaryBox = Checkbutton(self.gui_mainWindow,
                                            text="Robot Boundaries",
                                            variable=self.checkBoundaryBoolVar,
                                            width=20,
                                            anchor='w')
        self.checkBoundaryBox.select()  # check by default
        self.checkBoundaryBox.grid(row=4, column=0)

        # error label
        self.errorText = tk.StringVar()
        self.errorLabel = tk.Label(self.gui_mainWindow,
                                   textvariable=self.errorText,
                                   fg="red").grid(row=5, column=0)
        self.errorText.set("")  # there are no errors to begin with
        '''
        -----------------------------------------
            gui_positionInfo
        -----------------------------------------
        '''

        self.gui_positionInfo_hidden = True  # keep track if info window is hidden or not

        # new window for zero pos information
        self.gui_positionInfo = tk.Toplevel()
        self.gui_positionInfo.title("LM-Move | Positional Info")
        self.gui_positionInfo.geometry("305x160")
        self.gui_positionInfo.resizable(False, False)
        self.gui_positionInfo.withdraw()

        # robot zero pos label
        self.robot_zeroPosText = tk.StringVar()
        self.robot_zeroPosLabel = tk.Label(
            self.gui_positionInfo,
            textvariable=self.robot_zeroPosText).grid(row=0, column=0)
        self.robot_zeroPosText.set("Robot Zero Position\n\nNone!\n")

        # previous robot zero pos label
        self.prev_robot_zeroPosText = tk.StringVar()
        self.prev_robot_zeroPosLabel = tk.Label(
            self.gui_positionInfo,
            textvariable=self.prev_robot_zeroPosText).grid(row=1, column=0)
        self.prev_robot_zeroPosText.set("Prev. Robot Zero Position\n\nNone!\n")

        # hand zero pos label
        self.hand_zeroPosText = tk.StringVar()
        self.hand_zeroPosLabel = tk.Label(
            self.gui_positionInfo,
            textvariable=self.hand_zeroPosText).grid(row=0, column=1)
        self.hand_zeroPosText.set("Hand Zero Position\n\nNone!\n")

        # previous hand zero pos label
        self.prev_hand_zeroPosText = tk.StringVar()
        self.prev_hand_zeroPosLabel = tk.Label(
            self.gui_positionInfo,
            textvariable=self.prev_hand_zeroPosText).grid(row=1, column=1)
        self.prev_hand_zeroPosText.set("Prev. Hand Zero Position\n\nNone!\n")

        # reset zero pos button
        self.resetButton = tk.Button(self.gui_positionInfo,
                                     text="Reset Robot Zero Position",
                                     command=self.resetZeroPos,
                                     width=20)
        self.resetButton.configure(bg="orange")
        self.resetButton.grid(row=2, columnspan=2)

        # subscribe to data
        self.gui_mainWindow.after(1, self.subscribeToTopic)
        # handle closing of GUI
        self.gui_mainWindow.protocol("WM_DELETE_WINDOW", self.onCloseQuit)
        self.gui_positionInfo.protocol("WM_DELETE_WINDOW", self.onCloseHide)
        # keep the GUI running
        self.gui_mainWindow.mainloop()
Example #5
0
def create_frame(top):
    font1 = "-family {Segoe UI} -size 12"
    Frame1 = tk.Frame(top)
    Frame1.place(relx=0.00, rely=0.26, relheight=0.6, relwidth=1)
    Frame1.configure(background="#d9d9d9")

    Label1 = tk.Label(Frame1)
    Label1.place(relx=0.0, rely=0, height=58, width=100)
    Label1.configure(background="#d9d9d9")
    Label1.configure(disabledforeground="#a3a3a3")
    Label1.configure(font=font1)
    Label1.configure(foreground="#000000")
    Label1.configure(text='''Sr.''')

    Label2 = tk.Label(Frame1)
    Label2.place(relx=0.1, rely=0, height=58, width=100)
    Label2.configure(background="#d9d9d9")
    Label2.configure(disabledforeground="#a3a3a3")
    Label2.configure(font=font1)
    Label2.configure(foreground="#000000")
    Label2.configure(text='''User Name''')

    Label3 = tk.Label(Frame1)
    Label3.place(relx=0.28, rely=0, height=58, width=100)
    Label3.configure(background="#d9d9d9")
    Label3.configure(disabledforeground="#a3a3a3")
    Label3.configure(font=font1)
    Label3.configure(foreground="#000000")
    Label3.configure(text='''Job Name''')

    Label4 = tk.Label(Frame1)
    Label4.place(relx=0.46, rely=0, height=58, width=100)
    Label4.configure(background="#d9d9d9")
    Label4.configure(disabledforeground="#a3a3a3")
    Label4.configure(font=font1)
    Label4.configure(foreground="#000000")
    Label4.configure(text='''Skills''')

    Label5 = tk.Label(Frame1)
    Label5.place(relx=.64, rely=0, height=58, width=100)
    Label5.configure(background="#d9d9d9")
    Label5.configure(disabledforeground="#a3a3a3")
    Label5.configure(font=font1)
    Label5.configure(foreground="#000000")
    Label5.configure(text='''Duration''')

    Label6 = tk.Label(Frame1)
    Label6.place(relx=.82, rely=0, height=58, width=100)
    Label6.configure(background="#d9d9d9")
    Label6.configure(disabledforeground="#a3a3a3")
    Label6.configure(font=font1)
    Label6.configure(foreground="#000000")
    Label6.configure(text='''Reject''')

    database = r"job.db"

    # create a database connection
    conn1 = create_connection(database)
    with conn1:
        cur1 = conn1.cursor()
        cur1.execute('SELECT * FROM applied')
        data1 = cur1.fetchall()  # Gets the data from the table

        for index, dat1 in enumerate(data1):
            jobID = dat1[0]
            username = dat1[1]
            conn2 = create_connection(database)
            with conn2:
                cur2 = conn2.cursor()
                cur2.execute(
                    'SELECT * FROM jobs WHERE id LIKE ?', (str(jobID),))
                data2 = cur2.fetchall()  # Gets the data from the table
                for index2, dat2 in enumerate(data2):
                    jobName = dat2[1]
                    skills = dat2[2]
                    duration = dat2[3]

            Label1 = tk.Label(Frame1)
            Label1.place(relx=0, rely=index/5+0.2, height=58, width=100)
            Label1.configure(background="#d9d9d9")
            Label1.configure(disabledforeground="#a3a3a3")
            Label1.configure(font=font1)
            Label1.configure(foreground="#000000")
            Label1.configure(text=index+1)

            Label2 = tk.Label(Frame1)
            Label2.place(relx=0.1, rely=index/5+0.2, height=58, width=100)
            Label2.configure(background="#d9d9d9")
            Label2.configure(disabledforeground="#a3a3a3")
            Label2.configure(font=font1)
            Label2.configure(foreground="#000000")
            Label2.configure(text=username)

            Label3 = tk.Label(Frame1)
            Label3.place(relx=0.28, rely=index/5+0.2, height=58, width=100)
            Label3.configure(background="#d9d9d9")
            Label3.configure(disabledforeground="#a3a3a3")
            Label3.configure(font=font1)
            Label3.configure(foreground="#000000")
            Label3.configure(text=jobName)

            Label4 = tk.Label(Frame1)
            Label4.place(relx=0.46, rely=index/5+0.2, height=58, width=100)
            Label4.configure(background="#d9d9d9")
            Label4.configure(disabledforeground="#a3a3a3")
            Label4.configure(font=font1)
            Label4.configure(foreground="#000000")
            Label4.configure(text=skills)

            Label5 = tk.Label(Frame1)
            Label5.place(relx=0.64, rely=index/5+0.2, height=58, width=100)
            Label5.configure(background="#d9d9d9")
            Label5.configure(disabledforeground="#a3a3a3")
            Label5.configure(font=font1)
            Label5.configure(foreground="#000000")
            Label5.configure(text=duration)

            Button1 = tk.Button(
                Frame1, command=lambda dat1=dat1: rejectApp(dat1[2], top))
            Button1.place(relx=0.82, rely=index/5+0.2, height=58, width=100)
            Button1.configure(activebackground="#ececec")
            Button1.configure(activeforeground="#000000")
            Button1.configure(background="#d9d9d9")
            Button1.configure(disabledforeground="#a3a3a3")
            Button1.configure(font=font1)
            Button1.configure(foreground="#000000")
            Button1.configure(highlightbackground="#d9d9d9")
            Button1.configure(highlightcolor="black")
            Button1.configure(pady="0")
            Button1.configure(text='''Reject''')
Example #6
0
def ConvertMultipleImages(outputFormat):
	try:
		global root
		global convertFilesPopup
		global convertString
		global convertOutputDir
		global console
		global scrollbar

		convertString = tk.StringVar()
		convertString.set("")
		convertOutputDir = tk.StringVar()
		convertOutputDir.set("")

		# Set the popup geometry and screen location
		x = root.winfo_x()
		y = root.winfo_y()
		w = root.winfo_width()
		h = root.winfo_height()
		popupWidth = 275
		popupHeight = 100
		convertFilesPopup = tk.Toplevel()
		convertFilesPopup.geometry("%dx%d+%d+%d" % (popupWidth, popupHeight, (x + w/2)-popupWidth/2, (y + h/2)-popupHeight/2))
		convertFilesPopup.transient(root)
		convertFilesPopup.iconbitmap("favicon.ico")
		convertFilesPopup.title("Convert texture files")

		# Set widgets
		tk.Label(convertFilesPopup, text="File(s): ").grid(row=1, column=0)
		tk.Entry(convertFilesPopup, textvariable=convertString).grid(row=1, column=1, columnspan=2)
		tk.Button(convertFilesPopup, text="Browse", command=lambda: convertString.set(tkfd.askopenfilenames(parent=convertFilesPopup))).grid(row=1, column=3)

		tk.Label(convertFilesPopup, text="Output Directory: ").grid(row=2, column=0)
		tk.Entry(convertFilesPopup, textvariable=convertOutputDir).grid(row=2, column=1, columnspan=2)
		tk.Button(convertFilesPopup, text="Browse", command=lambda: convertOutputDir.set(tkfd.askdirectory(parent=root))).grid(row=2, column=3)

		proceed = [False] # Python 2 won't let you do assignment in lambdas... unless you're assigning to a list :V

		tk.Button(convertFilesPopup, text="Okay", command=lambda: proceed.__setitem__(0,True)).grid(row=3, column=1)

		if outputFormat == "PNG-DAT":
			console.insert(tk.END, "\nWarning! The old DAT format is no longer supported by 100% Orange Juice. Your output\nfiles will not work in the current version of the game.\n")

		# Loop the convertFilesPopup dialogue while we wait for the Okay button to be pressed
		while True:
			if convertFilesPopup.winfo_exists() == False:
				raise PopupClosedError()
			elif proceed[0] == True:
				convertFilesPopup.destroy()
				break
			else:
				convertFilesPopup.update_idletasks()
				convertFilesPopup.update()

		fileList = ParseMultipleFilenames(convertString.get())

		counter = 0
		imagePathList = []
		for path in fileList:
			GetTextureInfo(path)
			outputTuple = ConvertTextureFile(path, outputFormat)
			outputData, outputName = outputTuple[0], outputTuple[1] 

			newPath = convertOutputDir.get() + "/" + outputName
			if newPath == path:
				continue # If newPath == path, that means we didn't convert the file, and we shouldn't try to rewrite it
			outputFile = open(newPath, "wb")
			outputFile.write(outputData)
			outputFile.close()

			imagePathList.append(GetTextureInfo(newPath))

		scrollbar.setImageList(imagePathList)

		# Finally, add a line to console saying how many images have been exported and where to
		lineToBeOutput = str(len(fileList)) + " image(s) exported to " + convertOutputDir.get() + "!\n"
		console.insert(tk.END, lineToBeOutput)
	except PopupClosedError as e:
		pass
	except Exception as e:
		console.insert(tk.END, traceback.format_exc())
Example #7
0
           DATE TEXT NOT NULL);''')

    i = 0
    for elem in data_proc:

        #conn.execute('''INSERT INTO DATA (ID, TITLE, URL, DATE) values (''' + str(i) + ''',''' + elem[0] + ''',''' +
        #elem[1] + ''',''' + elem[2] + ''');''')
        conn.execute(
            '''INSERT INTO DATA (TITLE, URL, DATE) values (?, ?, ?)''',
            (elem[0], elem[1], elem[2]))
        i += 1

    conn.close()

    tkMessageBox.showinfo("Almacenar", "BD creada correctamente")


# TKKINTER

top = Tkinter.Tk()

B1 = Tkinter.Button(top, text="Almacenar", justify="left", command=almacenar)
B2 = Tkinter.Button(top, text="Listar", justify="left")
B3 = Tkinter.Button(top, text="Buscar", justify="left")

B1.pack(side="left")
B2.pack(side="left")
B3.pack(side="left")

top.mainloop()
Example #8
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font9 = "-family {Roboto} -size 9"
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font=font9)
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("757x480+300+108")
        top.title("VSM")
        top.configure(background="#ededed")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.MuatDokumen = tk.Button(top)
        self.MuatDokumen.place(relx=0.042, rely=0.086, height=23, width=114)
        self.MuatDokumen.configure(activebackground="#ececec")
        self.MuatDokumen.configure(activeforeground="#000000")
        self.MuatDokumen.configure(background="#2196f3")
        self.MuatDokumen.configure(
            command=lambda: self.start_submit_thread(self.fileopen))
        self.MuatDokumen.configure(disabledforeground="#a3a3a3")
        self.MuatDokumen.configure(font="-family {Roboto Medium} -size 9")
        self.MuatDokumen.configure(foreground="#ffffff")
        self.MuatDokumen.configure(highlightbackground="#d9d9d9")
        self.MuatDokumen.configure(highlightcolor="black")
        self.MuatDokumen.configure(pady="0")
        self.MuatDokumen.configure(text='''Muat Dokumen''')

        self.Frame1 = tk.Frame(top)
        self.Frame1.place(relx=0.042,
                          rely=0.193,
                          relheight=0.680,
                          relwidth=0.29)

        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")
        self.Frame1.configure(background="#ffffff")
        self.Frame1.configure(highlightbackground="#d9d9d9")
        self.Frame1.configure(highlightcolor="black")
        self.Frame1.configure(width=205)

        self.Label1 = tk.Label(self.Frame1)
        self.Label1.place(relx=0.024, rely=0.0, height=21, width=111)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#ffffff")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font="-family {Roboto Medium} -size 9")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Vector Space Model''')

        self.Frame2 = tk.Frame(self.Frame1)
        self.Frame2.place(relx=0.050,
                          rely=0.068,
                          relheight=0.32,
                          relwidth=0.902)
        self.Frame2.configure(relief='groove')
        self.Frame2.configure(borderwidth="2")
        self.Frame2.configure(relief="groove")
        self.Frame2.configure(background="#ededed")
        self.Frame2.configure(highlightbackground="#d9d9d9")
        self.Frame2.configure(highlightcolor="black")
        self.Frame2.configure(width=185)

        self.BOW = tk.Radiobutton(self.Frame2)
        self.BOW.place(relx=0.027, rely=0.048, relheight=0.238, relwidth=0.546)
        self.BOW.configure(activebackground="#ececec")
        self.BOW.configure(activeforeground="#000000")
        self.BOW.configure(background="#ededed")
        self.BOW.configure(disabledforeground="#a3a3a3")
        self.BOW.configure(foreground="#000000")
        self.BOW.configure(highlightbackground="#d9d9d9")
        self.BOW.configure(highlightcolor="black")
        self.BOW.configure(justify='left')
        self.BOW.configure(state='disabled')
        self.BOW.configure(text='''Bag Of Words''')

        self.D2V = tk.Radiobutton(self.Frame2)
        self.D2V.place(relx=0.020, rely=0.35, relheight=0.209, relwidth=0.411)
        self.D2V.configure(activebackground="#ececec")
        self.D2V.configure(activeforeground="#000000")
        self.D2V.configure(background="#ededed")
        self.D2V.configure(disabledforeground="#a3a3a3")
        self.D2V.configure(font="-family {Roboto} -size 9")
        self.D2V.configure(foreground="#000000")
        self.D2V.configure(highlightbackground="#d9d9d9")
        self.D2V.configure(highlightcolor="black")
        self.D2V.configure(justify='left')
        self.D2V.configure(state='disabled')
        self.D2V.configure(text='''Doc2Vec''')

        self.MulaiVSM = tk.Button(self.Frame2)
        self.MulaiVSM.place(relx=0.050, rely=0.65, height=23, width=149)
        self.MulaiVSM.configure(activebackground="#ececec")
        self.MulaiVSM.configure(activeforeground="#000000")
        self.MulaiVSM.configure(background="#2196f3")
        self.MulaiVSM.configure(disabledforeground="#a3a3a3")
        self.MulaiVSM.configure(font="-family {Roboto Medium} -size 9")
        self.MulaiVSM.configure(foreground="#ffffff")
        self.MulaiVSM.configure(highlightbackground="#d9d9d9")
        self.MulaiVSM.configure(highlightcolor="black")
        self.MulaiVSM.configure(pady="0")
        self.MulaiVSM.configure(state='disabled')
        self.MulaiVSM.configure(text='''Mulai Pembentukan VSM''')

        self.Label2 = tk.Label(self.Frame1)
        self.Label2.place(relx=0.024, rely=0.4, height=20, width=106)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#ffffff")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(font="-family {Roboto Medium} -size 9")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Metode Klasifikasi''')

        self.Frame3 = tk.Frame(self.Frame1)
        self.Frame3.place(relx=0.049, rely=0.47, relheight=0.5, relwidth=0.902)
        self.Frame3.configure(relief='groove')
        self.Frame3.configure(borderwidth="2")
        self.Frame3.configure(relief="groove")
        self.Frame3.configure(background="#ededed")
        self.Frame3.configure(highlightbackground="#d9d9d9")
        self.Frame3.configure(highlightcolor="black")
        self.Frame3.configure(width=185)

        self.MNB = tk.Radiobutton(self.Frame3)
        self.MNB.place(relx=0.027, rely=0.04, relheight=0.192, relwidth=0.876)
        self.MNB.configure(activebackground="#ececec")
        self.MNB.configure(activeforeground="#000000")
        self.MNB.configure(background="#ededed")
        self.MNB.configure(disabledforeground="#a3a3a3")
        self.MNB.configure(font="-family {Roboto} -size 9")
        self.MNB.configure(foreground="#000000")
        self.MNB.configure(highlightbackground="#d9d9d9")
        self.MNB.configure(highlightcolor="black")
        self.MNB.configure(justify='left')
        self.MNB.configure(state='disabled')
        self.MNB.configure(text='''Multinomial Naive Bayes''')

        self.LogReg = tk.Radiobutton(self.Frame3)
        self.LogReg.place(relx=0.027,
                          rely=0.20,
                          relheight=0.192,
                          relwidth=0.714)
        self.LogReg.configure(activebackground="#ececec")
        self.LogReg.configure(activeforeground="#000000")
        self.LogReg.configure(background="#ededed")
        self.LogReg.configure(disabledforeground="#a3a3a3")
        self.LogReg.configure(font="-family {Roboto} -size 9")
        self.LogReg.configure(foreground="#000000")
        self.LogReg.configure(highlightbackground="#d9d9d9")
        self.LogReg.configure(highlightcolor="black")
        self.LogReg.configure(justify='left')
        self.LogReg.configure(state='disabled')
        self.LogReg.configure(text='''Logistic Regression''')

        self.SVM = tk.Radiobutton(self.Frame3)
        self.SVM.place(relx=0.027, rely=0.37, relheight=0.192, relwidth=0.854)
        self.SVM.configure(activebackground="#ececec")
        self.SVM.configure(activeforeground="#000000")
        self.SVM.configure(background="#ededed")
        self.SVM.configure(disabledforeground="#a3a3a3")
        self.SVM.configure(font="-family {Roboto} -size 9")
        self.SVM.configure(foreground="#000000")
        self.SVM.configure(highlightbackground="#d9d9d9")
        self.SVM.configure(highlightcolor="black")
        self.SVM.configure(justify='left')
        self.SVM.configure(state='disabled')
        self.SVM.configure(text='''Support Vector Machine''')

        self.MulaiKlasifikasi = tk.Button(top)
        self.MulaiKlasifikasi.place(relx=0.042,
                                    rely=0.89,
                                    height=23,
                                    width=100)
        self.MulaiKlasifikasi.configure(activebackground="#ececec")
        self.MulaiKlasifikasi.configure(activeforeground="#000000")
        self.MulaiKlasifikasi.configure(background="#2196f3")
        self.MulaiKlasifikasi.configure(disabledforeground="#a3a3a3")
        self.MulaiKlasifikasi.configure(font="-family {Roboto Medium} -size 9")
        self.MulaiKlasifikasi.configure(foreground="#ffffff")
        self.MulaiKlasifikasi.configure(highlightbackground="#d9d9d9")
        self.MulaiKlasifikasi.configure(highlightcolor="black")
        self.MulaiKlasifikasi.configure(pady="0")
        self.MulaiKlasifikasi.configure(state='disabled')
        self.MulaiKlasifikasi.configure(text='''Mulai Klasifikasi''')

        self.Hitung = tk.Button(top)
        self.Hitung.place(relx=0.202, rely=0.89, height=23, width=97)
        self.Hitung.configure(activebackground="#ececec")
        self.Hitung.configure(activeforeground="#000000")
        self.Hitung.configure(background="#2196f3")
        self.Hitung.configure(disabledforeground="#a3a3a3")
        self.Hitung.configure(font="-family {Roboto Medium} -size 9")
        self.Hitung.configure(foreground="#ffffff")
        self.Hitung.configure(highlightbackground="#d9d9d9")
        self.Hitung.configure(highlightcolor="black")
        self.Hitung.configure(pady="0")
        self.Hitung.configure(state='disabled')
        self.Hitung.configure(text='''Hitung AUROC''')

        self.Path_Field = tk.Entry(top)
        self.Path_Field.place(relx=0.24, rely=0.086, height=25, relwidth=0.713)
        self.Path_Field.configure(background="white")
        self.Path_Field.configure(state='readonly')
        self.Path_Field.configure(disabledforeground="#a3a3a3")
        self.Path_Field.configure(font="TkFixedFont")
        self.Path_Field.configure(foreground="#000000")
        self.Path_Field.configure(highlightbackground="#d9d9d9")
        self.Path_Field.configure(highlightcolor="black")
        self.Path_Field.configure(insertbackground="black")
        self.Path_Field.configure(selectbackground="#c4c4c4")
        self.Path_Field.configure(selectforeground="black")
        self.Path_Field.configure(takefocus="0")

        self.Scrolledtext1 = ScrolledText(top)
        self.Scrolledtext1.place(relx=0.354,
                                 rely=0.26,
                                 relheight=0.68,
                                 relwidth=0.595)
        self.Scrolledtext1.configure(background="white")
        self.Scrolledtext1.configure(font="TkTextFont")
        self.Scrolledtext1.configure(foreground="black")
        self.Scrolledtext1.configure(highlightbackground="#d9d9d9")
        self.Scrolledtext1.configure(highlightcolor="black")
        self.Scrolledtext1.configure(insertbackground="black")
        self.Scrolledtext1.configure(insertborderwidth="3")
        self.Scrolledtext1.configure(state='disabled')
        self.Scrolledtext1.configure(selectbackground="#c4c4c4")
        self.Scrolledtext1.configure(selectforeground="black")
        self.Scrolledtext1.configure(takefocus="0")
        self.Scrolledtext1.configure(width=10)
        self.Scrolledtext1.configure(wrap="none")

        self.TProgressbar1 = ttk.Progressbar(top,
                                             length=420,
                                             mode="indeterminate")
        self.TProgressbar1.place(relx=0.354,
                                 rely=0.193,
                                 relwidth=0.594,
                                 relheight=0.0,
                                 height=20)
import Tkinter as tk

counter = 0 
def counter_label(label):
  counter = 0
  def count():
    global counter
    counter += 1
    label.config(text=str(counter))
    label.after(1000, count)
  count()
 
 
root = tk.Tk()
root.title("Counting Seconds")
label = tk.Label(root, fg="dark green")
label.pack()
counter_label(label)
button = tk.Button(root, text='Stop', width=25, command=root.destroy)
button.pack()
root.mainloop()
Example #10
0
	eget euismod purus tempor a. Vestibulum sit amet rhoncus ipsum. Nam
	aliquet tellus a risus elementum, eu ullamcorper sem sodales. Cras
	fermentum metus nec elit eleifend scelerisque. Phasellus nec ligula
	at lacus bibendum bibendum ut et justo. Cras scelerisque, mauris
	auctor sollicitudin interdum, leo metus commodo metus, bibendum
	bibendum eros nulla efficitur velit. Aenean at nibh at dui interdum
	aliquet ac et metus. In aliquam eleifend dignissim. Ut sem dui,
	fringilla viverra faucibus auctor, porttitor sed felis. Vestibulum
	maximus facilisis rhoncus.
	
	Vestibulum auctor vel diam et convallis. Duis id sapien ac neque
	venenatis faucibus et a nisl. Ut condimentum risus eu dolor lacinia,
	in finibus est facilisis. Phasellus vel odio ornare, commodo tortor
	eget, placerat velit. Fusce ullamcorper imperdiet sagittis. Morbi
	varius metus in lacus consectetur porttitor. Duis facilisis molestie
	est a gravida. Suspendisse ullamcorper porta lobortis. Aliquam nec
	iaculis elit.
	""")
    text.pack()
    button0 = tkinter.Button(frame,
                             text="Continue",
                             width=25,
                             command=frame.destroy)
    button0.pack(side='bottom')
    button1 = tkinter.Button(frame, text='One', width=25, command=adv1)
    button1.pack(side='left')
    button2 = tkinter.Button(frame, text='Two', width=25, command=adv2)
    button2.pack(side='right')
    break
main.mainloop()
import Tkinter

top = Tkinter.Tk()

top.title("Titulo chido")
top.geometry("300x300")

lbla=Tkinter.Label(top, text="Usuario", bg = "#a1dbcd")

entra= Tkinter.Entry(top)

lblb=Tkinter.Label(top, text="Contrasena")

entrb= Tkinter.Entry(top)

btna = Tkinter.Button(top, text ="Ingresa")
"""
Cambia el orden de las siguientes linesas 
y comenta lo que sucede
"""
lbla.pack()
entra.pack()
lblb.pack()
entrb.pack()
btna.pack()


top.mainloop()

"""
Ejercicio:
			((button_text3.get() != "") and (button_text3.get() == button_text6.get() == button_text9.get())) or
			((button_text1.get() != "") and (button_text1.get() == button_text5.get() == button_text9.get())) or
			((button_text3.get() != "") and (button_text3.get() == button_text5.get() == button_text7.get()))):
		r1 = tk.Tk()
		r1.title("Zero Cross Game")
		w = tk.Label(r1, text='Game winner is  ' + buttonVariable.get() +'', height=20, width=20) 
		w.pack() 
		r1.mainloop()


r = tk.Tk()
r.title("Zero Cross Game")


button_text1 = tk.StringVar()
button1 = tk.Button(r, textvariable=button_text1, command= lambda: changeText(button_text1), height=5, width=10)
button1.grid(row=0, column=0)

button_text2 = tk.StringVar()
button2 = tk.Button(r, textvariable=button_text2, command= lambda: changeText(button_text2), height=5, width=10)
button2.grid(row=0, column=1)

button_text3 = tk.StringVar()
button3 = tk.Button(r, textvariable=button_text3, command= lambda: changeText(button_text3), height=5, width=10)
button3.grid(row=0, column=2)

button_text4 = tk.StringVar()
button4 = tk.Button(r, textvariable=button_text4, command= lambda: changeText(button_text4), height=5, width=10)
button4.grid(row=1, column=0)

button_text5 = tk.StringVar()
    def __init__(self, root):
        """ Instanciar elementos gráficos (widgets) e ações atreladas. """
        # Definição de Cores ========================================= #
        # ============================================================ #
        BGCOLORBOX = (1.000, 1.000, 1.000)
        BGCOLORAPL = (0.392, 0.584, 0.929)
        BGCOLORSLT = (0.031, 0.572, 0.815)

        # Definição de Atributos ===================================== #
        # ============================================================ #

        # Janela gráfica de origem da aplicação.
        self._root = root

        # Título da aplicação.
        self._aptitle = u"Oceanop - Meteo-Oceanografia Operacional"

        # Subtítulo da aplicação.
        self._apsubtitle = u"..."

        # Bancos de dados disponíveis e chaves criptografadas de acesso.
        BDOCNPROD_MAINPATH = ('eNoLdTUL8g6Id3cJ1nd0DTIJMfNwdwgI8ncBAFU2BsQ=')
        BDOCNDESV_MAINPATH = ('eNoLdTUL8tYPBZEGBg4ursFhAC4gBNw=')
        self._dbs = OrderedDict([(u"PROD", BDOCNPROD_MAINPATH),
                                 (u"DESV", BDOCNDESV_MAINPATH)])
        # Instância do BD.
        self._DBVIEW = u"UE6RK"

        # Frame Principal ============================================ #
        # ============================================================ #
        self._mainfrm = tki.Frame(self._root, bg=rgb2hex(BGCOLORAPL),
                                  bd=0, relief=tki.FLAT)
        # Barra de Opções.
        self._menubar = tki.Menu(self._mainfrm)
        # Barra/menu "Arquivo".
        menu = tki.Menu(self._menubar, tearoff=0)
        menu.add_command(label=u"Sair", command=lambda rt=self._root:
                         (rt.destroy(), plt.close('all')))
        self._menubar.add_cascade(label=u"Arquivo", menu=menu)

        # Barra/menu "Colorbar".
        menu = tki.Menu(self._menubar, tearoff=0)
        menu.user_cmap_intens = tki.Menu(menu, tearoff=0)
        self._user_int = tki.IntVar()
        menu.user_cmap_intens.add_radiobutton(label=ur'jet',
                                              value=0, variable=self._user_int)
        menu.user_cmap_intens.add_radiobutton(label=ur'hvs',
                                              value=1, variable=self._user_int)
        menu.user_cmap_intens.add_radiobutton(label=ur'ocean',
                                              value=2, variable=self._user_int)

        menu.add_cascade(label=u"Intens.", menu=menu.user_cmap_intens)
        self._user_int.set(0)

        menu.user_cmap_direc = tki.Menu(menu, tearoff=0)
        self._user_dir = tki.IntVar()
        menu.user_cmap_direc.add_radiobutton(label=ur'jet',
                                             value=0, variable=self._user_dir)
        menu.user_cmap_direc.add_radiobutton(label=ur'hvs',
                                             value=1, variable=self._user_dir)
        menu.user_cmap_direc.add_radiobutton(label=ur'ocean',
                                             value=2, variable=self._user_dir)

        menu.add_cascade(label=u"Direc.", menu=menu.user_cmap_direc)
        self._user_dir.set(1)

        menu.user_cmap_EI = tki.Menu(menu, tearoff=0)
        self._user_EI = tki.IntVar()
        menu.user_cmap_EI.add_radiobutton(label=ur'jet',
                                          value=0, variable=self._user_EI)
        menu.user_cmap_EI.add_radiobutton(label=ur'hvs',
                                          value=1, variable=self._user_EI)
        menu.user_cmap_EI.add_radiobutton(label=ur'ocean',
                                          value=2, variable=self._user_EI)

        menu.add_cascade(label=u"Echo I.", menu=menu.user_cmap_EI)
        self._user_EI.set(0)

        menu.user_cmap_CM = tki.Menu(menu, tearoff=0)
        self._user_CM = tki.IntVar()
        menu.user_cmap_CM.add_radiobutton(label=ur'jet',
                                          value=0, variable=self._user_CM)
        menu.user_cmap_CM.add_radiobutton(label=ur'hvs',
                                          value=1, variable=self._user_CM)
        menu.user_cmap_CM.add_radiobutton(label=ur'ocean',
                                          value=2, variable=self._user_CM)

        menu.add_cascade(label=u"Cor M.", menu=menu.user_cmap_CM)
        self._user_CM.set(0)

        self._menubar.add_cascade(label=u"Colormap", menu=menu)

        # Associação da barra de opções ao frame principal.
        self._mainfrm.master.config(menu=self._menubar)

        # Frame de Período e Banco #
        # ============================================================ #
        self._dbdtfrm = tki.Frame(self._mainfrm, bg=rgb2hex(BGCOLORAPL),
                                  bd=2, relief=tki.GROOVE)
        self._dbdtfrm.pack(fill=tki.X, padx=6, pady=4, side=tki.TOP)

        # Subframe de Período #
        # ============================================================ #
        self._datefrm = tki.Frame(self._dbdtfrm, bg=rgb2hex(BGCOLORAPL),
                                  bd=0, relief=tki.GROOVE)
        self._datefrm.pack(padx=1, pady=0, side=tki.LEFT, fill=tki.X,
                           expand=tki.YES)
        # Variável mutante da data inicial declarada (previamente
        # escolhida há 30 dias daquele de hoje).
        self._idate = tki.StringVar()
        self._idate.set((dtm.datetime.utcnow() -
                         dtm.timedelta(hours=720)).strftime(u"%d/%m/%Y" +
                                                            u" %H:00:00"))
        # Variável mutante da data final declarada (previamente
        # escolhida como o dia de hoje).
        self._fdate = tki.StringVar()
        self._fdate.set(dtm.datetime.utcnow().strftime(u"%d/%m/%Y %H:00:00"))
        # Rótulo "Período".
        self._datefrm_rot = tki.Label(self._datefrm, bg=rgb2hex(BGCOLORAPL),
                                      bd=0, fg='white', text=u"Período:",
                                      font=('Verdana', '9', 'bold'),
                                      relief=tki.FLAT, justify=tki.RIGHT)
        self._datefrm_rot.grid(column=0, row=1, rowspan=2, padx=4,
                               pady=0, sticky=tki.NSEW)
        # Data Ininal.
        tki.Label(self._datefrm, bd=0, bg=rgb2hex(BGCOLORAPL), fg='white',
                  text=u"Data Inicial", font=('Verdana', '8', 'bold'),
                  relief=tki.FLAT, justify=tki.CENTER).grid(column=2, row=0,
                                                            padx=2, pady=0,
                                                            sticky=tki.EW)
        # Data Final.
        tki.Label(self._datefrm, bd=0, bg=rgb2hex(BGCOLORAPL), fg='white',
                  text=u"Data Final", font=('Verdana', '8', 'bold'),
                  relief=tki.FLAT, justify=tki.CENTER).grid(column=6, row=0,
                                                            padx=2, pady=0,
                                                            sticky=tki.EW)
        # Campo de entrada da data inicial de consulta
        self._idatent = tki.Entry(self._datefrm, bd=3, width=19,
                                  textvariable=self._idate, justify=tki.CENTER)
        self._idatent.grid(column=2, row=1, rowspan=2, padx=10, pady=2,
                           ipady=2, sticky=tki.EW)
        # Campo de entrada da data final de consulta
        self._fdatent = tki.Entry(self._datefrm, bd=3, width=19,
                                  textvariable=self._fdate, justify=tki.CENTER)
        self._fdatent.grid(column=6, row=1, rowspan=2, padx=10, pady=2,
                           ipady=2, sticky=tki.E)

        # Subframe de BD #
        # ============================================================ #
        self._dbfrm = tki.Frame(self._dbdtfrm, bg=rgb2hex(BGCOLORAPL),
                                bd=0, relief=tki.GROOVE)
        self._dbfrm.pack(padx=1, pady=0, side=tki.BOTTOM)

        # Opções de BDs.
        self._dbfrm_name = tki.Label(self._dbfrm, bg=rgb2hex(BGCOLORAPL),
                                     fg='white', bd=0, text=u"Banco:",
                                     font=('Verdana', '9', 'bold'),
                                     relief=tki.FLAT, justify=tki.LEFT)
        self._dbfrm_name.grid(column=7, row=1, rowspan=2, padx=10,
                              pady=2, sticky=tki.NSEW)

        # Variável mutante do BD selecionado.
        self._dbvar = tki.StringVar()

        # Menu de BDs disponíveis para consulta.
        self._dbopt = tki.OptionMenu(self._dbfrm, self._dbvar,
                                     *self._dbs.keys(), command=self.askucds)
        self._dbopt.grid(column=8, row=1, rowspan=1, padx=4, pady=0,
                         sticky=tki.NSEW)

        # Frame de UCDs
        # ============================================================ #
        self._ucdfrm = tki.Frame(self._mainfrm, bg=rgb2hex(BGCOLORAPL),
                                 bd=2, relief=tki.GROOVE)
        self._ucdfrm.pack(fill=tki.BOTH, padx=6, pady=4, side=tki.LEFT)

        self._ucdsmenub = tki.Label(self._ucdfrm, bg=rgb2hex(BGCOLORAPL),
                                    bd=0, fg='white', text=u"UCDs:",
                                    font=('Verdana', '9', 'bold'),
                                    relief=tki.FLAT, justify=tki.CENTER)

        self._ucdsmenub.grid(column=0, columnspan=1, row=0, rowspan=2,
                             padx=2, pady=0, sticky=tki.N)

        # Listagem de UCDs disponíveis para consulta.
        self._ucdslbx = tki.Listbox(self._ucdfrm, bd=1,
                                    selectmode=tki.SINGLE,
                                    width=20, height=6,
                                    selectborderwidth=2,
                                    setgrid=tki.NO, exportselection=tki.FALSE,
                                    selectbackground=rgb2hex(BGCOLORSLT),
                                    font=('Default', '8', 'normal'))

        self._ucdslly = tki.Scrollbar(self._ucdfrm, bd=0, orient=tki.VERTICAL,
                                      command=self._ucdslbx.yview)

        self._ucdslbx.grid(column=1, columnspan=1,
                           row=0, rowspan=2, padx=0, pady=0, sticky=tki.NS)
        self._ucdslly.grid(column=2, columnspan=2,
                           row=0, rowspan=2, padx=0, pady=0, sticky=tki.NSEW)

        self._ucdslbx.configure(yscrollcommand=self._ucdslly.set)
        self._root.update_idletasks()

        # Menu de UCDs para consulta facilitada.
        self._ucdsmenu = tki.Menu(self._root, tearoff=0)

        # Subframe de Setup #
        # ============================================================ #
        self._stpfrm = tki.Frame(self._mainfrm, bg=rgb2hex(BGCOLORAPL),
                                 bd=2, relief=tki.GROOVE)
        self._stpfrm.pack(expand=tki.YES, padx=1, pady=1, side=tki.LEFT)

        # Variável mutante do setup selecionado.
        self._stpvar = tki.StringVar()

        self._stplabel = tki.Label(self._stpfrm, bg=rgb2hex(BGCOLORAPL),
                                   bd=0, fg='white', text=u"Setups:",
                                   font=('Verdana', '9', 'bold'),
                                   relief=tki.FLAT, justify=tki.CENTER)
        self._stplabel.grid(column=1, columnspan=1, row=0, rowspan=1,
                            padx=1, pady=1, sticky=tki.N)

        self._stpkeys = tki.Label(self._stpfrm, bg=rgb2hex(BGCOLORAPL),
                                  relief=tki.FLAT)
        self._stpkeys.grid(column=1, columnspan=1, row=3, rowspan=2,
                           padx=1, pady=1, sticky=tki.N)
        MODES = [("Int./Dir.", "1"), ("Echo Int.", "2"), ("Correlation", "3")]

        for text, mode in MODES:
            b = tki.Radiobutton(self._stpkeys, text=text, fg='white',
                                bg=rgb2hex(BGCOLORAPL), 
                                selectcolor=rgb2hex(BGCOLORAPL),
                                variable=self._stpvar, value=mode)
            b.pack(anchor=tki.W)

        self._stpvar.set("1")

        # Subframe de Mensagem #
        # ============================================================ #
        self._msgfrm = tki.Frame(self._mainfrm, bg=rgb2hex(BGCOLORAPL),
                                 bd=0, relief=tki.FLAT)
        self._msgfrm.pack(expand=tki.YES, padx=0, pady=0, side=tki.LEFT)
        self._qrymsg = tki.Label(self._msgfrm, bg=rgb2hex(BGCOLORAPL),
                                 bd=0, fg='white', text=u"Mensagem:",
                                 font=('Verdana', '9', 'bold'),
                                 relief=tki.FLAT, justify=tki.CENTER)

        self._qrymsg.grid(column=2, columnspan=1, row=1, rowspan=1,
                          padx=1, pady=1, sticky=tki.N)

        self._msg = tki.StringVar()
        self._msg.set("Escolha o Banco")
        self._qrymsgbox = tki.Label(self._msgfrm, bg=rgb2hex(BGCOLORAPL), bd=1,
                                    width=25, font=('Verdana', '9', 'bold'),
                                    fg='yellow', textvariable=self._msg,
                                    justify=tki.CENTER)
        self._qrymsgbox.grid(column=2, columnspan=1, row=2, rowspan=1,
                             padx=1, pady=1, sticky=tki.N)

        # Subframe de Consulta #
        # ============================================================ #
        self._qryfrm = tki.Frame(self._mainfrm, bg=rgb2hex(BGCOLORBOX),
                                 bd=3, relief=tki.SUNKEN)
        self._qryfrm.pack(expand=tki.YES, padx=0, pady=0, side=tki.RIGHT)

        # Botão de plotagem dos dados desejados
        # (condicionalmente e previamente desabilitado).
        self._qrybt = tki.Button(self._qryfrm, bd=1, text=u"Consulta",
                                 font=('Default', '10', 'bold'),
                                 command=self.askdata)
        self._qrybt.grid(column=3, row=1, rowspan=1, padx=0, pady=1,
                         ipadx=1, ipady=1)
        self._qrybt["state"] = tki.DISABLED

        self._root.update()

        self._mainfrm.pack(fill=tki.BOTH, padx=0, pady=0, side=tki.TOP)

        # Carregamento de agrupamentos de UCDs definidos pela aplicação.
        self._uselvar = tki.StringVar()
        self._ucdslbx.curselection()
            "Please enter a valid expression in lower case 'x' containing:\n1. x\n2. log(x)\n3. e(x)\n4. sqrt(x)\n5. x**n (n is any integer)"
        )


def exit1():
    window.destroy()


def clear():
    plt.close()
    txt.delete(0, 'end')


#Creating Buttons

btn = tk.Button(frame2, text="cos(deg)", width=7, height=2, command=cos)
btn.grid(row=2, column=0, padx=2, pady=2)

btn = tk.Button(frame2, text="sin(deg)", width=7, height=2, command=sin)
btn.grid(row=2, column=1, padx=2, pady=2)

btn = tk.Button(frame2, text="tan(deg)", width=7, height=2, command=tan)
btn.grid(row=2, column=2, padx=2, pady=2)

btn = tk.Button(frame2, text="exp", width=7, height=2, command=exp)
btn.grid(row=3, column=0, padx=2, pady=2)

btn = tk.Button(frame2, text="sqrt", width=7, height=2, command=sqrt)
btn.grid(row=3, column=1, padx=2, pady=2)

btn = tk.Button(frame2, text="log", width=7, height=2, command=log)
Example #15
0
    def __init__(self, top=None):
        self.yh = th.Thread(target=self.run_youtube_command,args=())
        self.tt = th.Thread(target=self.run_twitter_command, args=())
        self.ct = th.Thread(target=self.run_chicago_command, args=())
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'

        top.geometry("500x300+547+229")
        top.minsize(1, 1)
        top.maxsize(1345, 668)
        top.resizable(1, 1)
        top.title("OSINT Project")
        top.configure(highlightcolor="black")

        self.Frame1 = tk.Frame(top)
        self.Frame1.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=0.4)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")

        self.Twitter = tk.Frame(top)
        self.Twitter.place(relx=0.4, rely=0.0, relheight=1.0, relwidth=0.6)
        self.Twitter.configure(relief='groove')
        self.Twitter.configure(borderwidth="2")
        self.Twitter.configure(relief="groove")

        self.Label1 = tk.Label(self.Twitter)
        self.Label1.place(relx=0.067, rely=0.1, height=21, width=100)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(anchor='w')
        self.Label1.configure(text='''Search Term:''')

        self.Label1_1 = tk.Label(self.Twitter)
        self.Label1_1.place(relx=0.067, rely=0.417, height=21, width=100)
        self.Label1_1.configure(activebackground="#f9f9f9")
        self.Label1_1.configure(anchor='w')
        self.Label1_1.configure(text='''Location:''')

        self.Label1_2 = tk.Label(self.Twitter)
        self.Label1_2.place(relx=0.067, rely=0.233, height=21, width=100)
        self.Label1_2.configure(activebackground="#f9f9f9")
        self.Label1_2.configure(anchor='w')
        self.Label1_2.configure(text='''Start Date:''')

        self.Label2 = tk.Label(self.Twitter)
        self.Label2.place(relx=0.067, rely=0.5, height=21, width=100)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(anchor='w')
        self.Label2.configure(text='''Radius:''')

        self.Label1_3 = tk.Label(self.Twitter)
        self.Label1_3.place(relx=0.067, rely=0.617, height=21, width=100)
        self.Label1_3.configure(activebackground="#f9f9f9")
        self.Label1_3.configure(anchor='w')
        self.Label1_3.configure(text='''Max Tweets:''')

        self.Label1_2 = tk.Label(self.Twitter)
        self.Label1_2.place(relx=0.067, rely=0.3, height=21, width=100)
        self.Label1_2.configure(activebackground="#f9f9f9")
        self.Label1_2.configure(anchor='w')
        self.Label1_2.configure(text='''End:''')

        self.collectTweets = tk.Button(self.Twitter)
        self.collectTweets.place(relx=0.067, rely=0.75, height=31, width=260)
        self.collectTweets.configure(activebackground="#f9f9f9")
        self.collectTweets.configure(background="#0fba0f")
        self.collectTweets.configure(command=self.run_twitter_thread)
        self.collectTweets.configure(padx="1")
        self.collectTweets.configure(pady="3")
        self.collectTweets.configure(text='''Collect''')

        self.twitter_query = tk.Entry(self.Twitter)
        self.twitter_query.place(relx=0.4, rely=0.1,height=23, relwidth=0.5)
        self.twitter_query.configure(background="white")
        self.twitter_query.configure(font="TkFixedFont")
        self.twitter_query.configure(selectbackground="blue")
        self.twitter_query.configure(selectforeground="white")
        self.twitter_query.configure(textvariable=gui_support.twitter_query)

        self.twitter_end_date = tk.Entry(self.Twitter)
        self.twitter_end_date.place(relx=0.4, rely=0.3,height=23, relwidth=0.5)
        self.twitter_end_date.configure(background="white")
        self.twitter_end_date.configure(font="TkFixedFont")
        self.twitter_end_date.configure(selectbackground="blue")
        self.twitter_end_date.configure(selectforeground="white")
        self.twitter_end_date.configure(textvariable=gui_support.twitter_end_date)

        self.twitter_max_tweets = tk.Entry(self.Twitter)
        self.twitter_max_tweets.place(relx=0.4, rely=0.617, height=23
                , relwidth=0.5)
        self.twitter_max_tweets.configure(background="white")
        self.twitter_max_tweets.configure(font="TkFixedFont")
        self.twitter_max_tweets.configure(selectbackground="blue")
        self.twitter_max_tweets.configure(selectforeground="white")
        self.twitter_max_tweets.configure(textvariable=gui_support.twitter_max_tweets)

        self.twitter_radius = tk.Entry(self.Twitter)
        self.twitter_radius.place(relx=0.4, rely=0.5,height=23, relwidth=0.5)
        self.twitter_radius.configure(background="white")
        self.twitter_radius.configure(font="TkFixedFont")
        self.twitter_radius.configure(selectbackground="blue")
        self.twitter_radius.configure(selectforeground="white")
        self.twitter_radius.configure(textvariable=gui_support.twitter_radius)

        self.twitter_location = tk.Entry(self.Twitter)
        self.twitter_location.place(relx=0.4, rely=0.417, height=23
                , relwidth=0.5)
        self.twitter_location.configure(background="white")
        self.twitter_location.configure(font="TkFixedFont")
        self.twitter_location.configure(selectbackground="blue")
        self.twitter_location.configure(selectforeground="white")
        self.twitter_location.configure(textvariable=gui_support.twitter_location)

        self.twitter_start_date = tk.Entry(self.Twitter)
        self.twitter_start_date.place(relx=0.4, rely=0.217, height=23
                , relwidth=0.5)
        self.twitter_start_date.configure(background="white")
        self.twitter_start_date.configure(font="TkFixedFont")
        self.twitter_start_date.configure(selectbackground="blue")
        self.twitter_start_date.configure(selectforeground="white")
        self.twitter_start_date.configure(textvariable=gui_support.twitter_start_date)

        self.Youtube = tk.Frame(top)
        self.Youtube.place(relx=0.4, rely=0.0, relheight=1.0, relwidth=0.6)
        self.Youtube.configure(relief='groove')
        self.Youtube.configure(borderwidth="2")
        self.Youtube.configure(relief="groove")

        self.collectYoutube_Btn = tk.Button(self.Youtube)
        self.collectYoutube_Btn.place(relx=0.067, rely=0.75, height=31, width=260)
        self.collectYoutube_Btn.configure(activebackground="#f9f9f9")
        self.collectYoutube_Btn.configure(background="#0fba0f")
        self.collectYoutube_Btn.configure(command=self.run_youtube_thread)
        self.collectYoutube_Btn.configure(text='''Collect Data''')

        self.youtube_keyword = tk.Label(self.Youtube)
        self.youtube_keyword.place(relx=0.333, rely=0.133, height=27, width=100)
        self.youtube_keyword.configure(activebackground="#f9f9f9")
        self.youtube_keyword.configure(text='''Keyword''')

        self.youtube_query = tk.Entry(self.Youtube)
        self.youtube_query.place(relx=0.2, rely=0.267,height=29, relwidth=0.6)
        self.youtube_query.configure(background="white")
        self.youtube_query.configure(font="TkDefaultFont")
        self.youtube_query.configure(selectbackground="blue")
        self.youtube_query.configure(selectforeground="white")
        self.youtube_query.configure(textvariable=gui_support.youtube_query)

        self.youtube_count = tk.Entry(self.Youtube)
        self.youtube_count.place(relx=0.2, rely=0.533,height=29, relwidth=0.6)
        self.youtube_count.configure(background="white")
        self.youtube_count.configure(font="TkDefaultFont")
        self.youtube_count.configure(selectbackground="blue")
        self.youtube_count.configure(selectforeground="white")
        self.youtube_count.configure(textvariable=gui_support.youtube_count)

        self.youtube_count_Label = tk.Label(self.Youtube)
        self.youtube_count_Label.place(relx=0.333, rely=0.4, height=27
                , width=100)
        self.youtube_count_Label.configure(activebackground="#f9f9f9")
        self.youtube_count_Label.configure(text='''Count''')

        self.Chicago = tk.Frame(top)
        self.Chicago.place(relx=0.4, rely=0.0, relheight=1.0, relwidth=0.6)
        self.Chicago.configure(relief='groove')
        self.Chicago.configure(borderwidth="2")
        self.Chicago.configure(relief="groove")

        self.Logo = tk.Frame(top)
        self.Logo.place(relx=0.4, rely=0.0, relheight=1.0, relwidth=0.6)
        self.Logo.configure(relief='groove')
        self.Logo.configure(borderwidth="2")
        self.Logo.configure(relief="groove")

        self.twitter_Btn = tk.Button(self.Frame1)
        self.twitter_Btn.place(relx=0.0, rely=0.083, height=31, relwidth=1)
        self.twitter_Btn.configure(activebackground="#f9f9f9")
        self.twitter_Btn.configure(background="#36bcff")
        self.twitter_Btn.configure(command=lambda : gui_support.raiseTwitter(self.Twitter))
        self.twitter_Btn.configure(pady="3m")
        self.twitter_Btn.configure(text='''Twitter''')

        self.quitBut = tk.Button(self.Frame1)
        self.quitBut.place(relx=0.0, rely=0.833, height=31, relwidth=1)
        self.quitBut.configure(activebackground="#f9f9f9")
        self.quitBut.configure(background="#631818")
        self.quitBut.configure(command=gui_support.checkExit)
        self.quitBut.configure(disabledforeground="#70101d")
        self.quitBut.configure(foreground="#ffffff")
        self.quitBut.configure(text='''Quit''')

        self.youtube_Btn = tk.Button(self.Frame1)
        self.youtube_Btn.place(relx=0.0, rely=0.25, height=31, relwidth=1)
        self.youtube_Btn.configure(activebackground="#f9f9f9")
        self.youtube_Btn.configure(background="#ff2448")
        self.youtube_Btn.configure(command=lambda : gui_support.raiseYoutube(self.Youtube))
        self.youtube_Btn.configure(text='''Youtube''')

        self.chicago_Btn = tk.Button(self.Frame1)
        self.chicago_Btn.place(relx=0.0, rely=0.417, height=31, relwidth=1)
        self.chicago_Btn.configure(activebackground="#f9f9f9")
        self.chicago_Btn.configure(background="#d8d847")
        self.chicago_Btn.configure(command=lambda : gui_support.raiseChicago(self.Chicago))
        self.chicago_Btn.configure(text='''Chicago Crime''')

        self.chicago_startDate_Label = tk.Label(self.Chicago)
        self.chicago_startDate_Label.place(relx=0.1, rely=0.083, height=21, width=100)
        self.chicago_startDate_Label.configure(activebackground="#f9f9f9")
        self.chicago_startDate_Label.configure(anchor='w')
        self.chicago_startDate_Label.configure(text='''Start Date:''')

        self.chicago_latse_Label = tk.Label(self.Chicago)
        self.chicago_latse_Label.place(relx=0.1, rely=0.517, height=21, width=100)
        self.chicago_latse_Label.configure(activebackground="#f9f9f9")
        self.chicago_latse_Label.configure(anchor='w')
        self.chicago_latse_Label.configure(text='''Lat SE:''')

        self.chicago_latnw_Label = tk.Label(self.Chicago)
        self.chicago_latnw_Label.place(relx=0.1, rely=0.35, height=21, width=100)
        self.chicago_latnw_Label.configure(activebackground="#f9f9f9")
        self.chicago_latnw_Label.configure(anchor='w')
        self.chicago_latnw_Label.configure(text='''Lat NW:''')

        self.chicago_longse_Label = tk.Label(self.Chicago)
        self.chicago_longse_Label.place(relx=0.5, rely=0.517, height=21, width=100)
        self.chicago_longse_Label.configure(activebackground="#f9f9f9")
        self.chicago_longse_Label.configure(anchor='w')
        self.chicago_longse_Label.configure(text='''Long SE:''')

        self.chicago_endDate_Label = tk.Label(self.Chicago)
        self.chicago_endDate_Label.place(relx=0.5, rely=0.083, height=21, width=100)
        self.chicago_endDate_Label.configure(activebackground="#f9f9f9")
        self.chicago_endDate_Label.configure(anchor='w')
        self.chicago_endDate_Label.configure(text='''End Date:''')

        self.chicago_longnw_Label = tk.Label(self.Chicago)
        self.chicago_longnw_Label.place(relx=0.5, rely=0.35, height=21, width=100)
        self.chicago_longnw_Label.configure(activebackground="#f9f9f9")
        self.chicago_longnw_Label.configure(anchor='w')
        self.chicago_longnw_Label.configure(text='''Long NW''')

        self.chicago_analysis = ttk.Combobox(self.Chicago)
        self.chicago_analysis.place(relx=0.1, rely=0.733, relheight=0.07, relwidth=0.5)
        self.chicago_analysis.configure(values=['Crime Type','Crime a week','Crime a month','Arrest Record'])
        self.chicago_analysis.set('Crime Type')
        self.chicago_analysis.configure(takefocus="")

        self.collectChicago = tk.Button(self.Chicago)
        self.collectChicago.place(relx=0.067, rely=0.833, height=31, width=260)
        self.collectChicago.configure(activebackground="#f9f9f9")
        self.collectChicago.configure(background="#0fba0f")
        self.collectChicago.configure(command=self.run_chicago_thread)
        self.collectChicago.configure(padx="1")
        self.collectChicago.configure(pady="3")
        self.collectChicago.configure(text='''Collect''')

        self.chicago_startDate = tk.Entry(self.Chicago)
        self.chicago_startDate.place(relx=0.1, rely=0.15, height=23
                , relwidth=0.333)
        self.chicago_startDate.configure(background="white")
        self.chicago_startDate.configure(font="TkFixedFont")
        self.chicago_startDate.configure(selectbackground="blue")
        self.chicago_startDate.configure(selectforeground="white")

        self.chicago_longnw = tk.Entry(self.Chicago)
        self.chicago_longnw.place(relx=0.5, rely=0.417,height=23, relwidth=0.333)
        self.chicago_longnw.configure(background="white")
        self.chicago_longnw.configure(font="TkFixedFont")
        self.chicago_longnw.configure(selectbackground="blue")
        self.chicago_longnw.configure(selectforeground="white")

        self.chicago_endDate = tk.Entry(self.Chicago)
        self.chicago_endDate.place(relx=0.5, rely=0.15, height=23, relwidth=0.367)

        self.chicago_endDate.configure(background="white")
        self.chicago_endDate.configure(font="TkFixedFont")
        self.chicago_endDate.configure(selectbackground="blue")
        self.chicago_endDate.configure(selectforeground="white")

        self.chicago_longse = tk.Entry(self.Chicago)
        self.chicago_longse.place(relx=0.5, rely=0.583,height=23, relwidth=0.333)
        self.chicago_longse.configure(background="white")
        self.chicago_longse.configure(font="TkFixedFont")
        self.chicago_longse.configure(selectbackground="blue")
        self.chicago_longse.configure(selectforeground="white")

        self.chicago_latse = tk.Entry(self.Chicago)
        self.chicago_latse.place(relx=0.1, rely=0.583,height=23, relwidth=0.333)
        self.chicago_latse.configure(background="white")
        self.chicago_latse.configure(font="TkFixedFont")
        self.chicago_latse.configure(selectbackground="blue")
        self.chicago_latse.configure(selectforeground="white")

        self.chicago_latnw = tk.Entry(self.Chicago)
        self.chicago_latnw.place(relx=0.1, rely=0.417,height=23, relwidth=0.333)
        self.chicago_latnw.configure(background="white")
        self.chicago_latnw.configure(font="TkFixedFont")
        self.chicago_latnw.configure(selectbackground="blue")
        self.chicago_latnw.configure(selectforeground="white")

        self.chicago_geoFenceLabel = tk.Label(self.Chicago)
        self.chicago_geoFenceLabel.place(relx=0.3, rely=0.283, height=21, width=150)
        self.chicago_geoFenceLabel.configure(activebackground="#f9f9f9")
        self.chicago_geoFenceLabel.configure(anchor='w')
        self.chicago_geoFenceLabel.configure(text='''Area of Interest''')

        self.analyze_Btn = tk.Button(self.Frame1)
        self.analyze_Btn.place(relx=0.0, rely=0.583, height=31, relwidth=1)
        self.analyze_Btn.configure(activebackground="#f9f9f9")
        self.analyze_Btn.configure(background="#40ff73")
        self.analyze_Btn.configure(command=lambda : gui_support.raiseAnalyze(self.Logo))
        self.analyze_Btn.configure(text='''Analyze Data''')

        self.logo = tk.Label(self.Logo)
        self.logo.place(relx=0.0, rely=0.0, height=300, width=300)
        self.logo.configure(activebackground="#f9f9f9")
        photo_location = os.path.join(prog_location,"./logo.png")
        global _img0
        _img0 = tk.PhotoImage(file=photo_location)
        self.logo.configure(image=_img0)

        self.twitter_query.insert(tk.END, "Trump")
        self.twitter_start_date.insert(tk.END, "2020-01-01")
        self.twitter_end_date.insert(tk.END, "2020-07-14")
        self.twitter_location.insert(tk.END, "41.83, -87.62")
        self.twitter_radius.insert(tk.END, "5km")
        self.twitter_max_tweets.insert(tk.END, "1000")

        self.chicago_latnw.insert(tk.END, "41.975121")
        self.chicago_latse.insert(tk.END, "41.978260")
        self.chicago_longnw.insert(tk.END, "-87.791649")
        self.chicago_longse.insert(tk.END, "-87.763931")
        self.chicago_startDate.insert(tk.END, "2019-01-01T12:00:00")
        self.chicago_endDate.insert(tk.END, "2019-07-16T14:00:00")

        self.youtube_query.insert(tk.END, "funny")
        self.youtube_count.insert(tk.END,10)
    def __init__(self, parent, title=None):
        global index,v2,v1
        Tk.Frame.__init__(self, parent)
        self.parent = parent
        if title == None:
            title = "Intelligent Video Editor"
        self.parent.title(title)
        menubar = Tk.Menu(self.parent)
        self.parent.config(menu=menubar)
        fileMenu = Tk.Menu(menubar)
        fileMenu.add_command(label="Open", underline=0, command=self.OnOpen)
        fileMenu.add_command(label="Exit", underline=1, command=_quit)
        menubar.add_cascade(label="File", menu=fileMenu)
        self.player = None
        self.videopanel = ttk.Frame(self.parent)
        self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH,expand=1)
        self.videopanel.pack(fill=Tk.BOTH,expand=1)
        ctrlpanel = ttk.Frame(self.parent)
        
        ctrlpanel1 = ttk.Frame(self.parent)
        ctrlpanel3 = ttk.Frame(self.parent)
        ctrlpanel2 = ttk.Frame(self.parent)
        ctrlpanel2.pack(side=BOTTOM,anchor=E)



       
        self.scale_var = Tk.DoubleVar()
        self.timeslider_last_val = ""
        self.timeslider = Tk.Scale(ctrlpanel, variable=self.scale_var, width=1.5,command=self.scale_sel,from_=0, to=1000, orient=Tk.HORIZONTAL, length=830)
        self.timeslider.pack(side=Tk.TOP, fill=Tk.X,expand=1)
        self.timeslider_last_update = time.time()


        style = ttk.Style()
        style.configure("TButton", foreground="white", background="blue")

        

        
        pause  = Tk.Button(ctrlpanel, text=" Pause ", command=self.OnPause,bg="blue",fg="white",relief=RAISED,bd=5)
        screenshot  = Tk.Button(ctrlpanel, text=" Screenshot ",bg="blue",fg="white",bd=5)
        plus5  = Tk.Button(ctrlpanel, text="   >>  ", command=self.plus5,bg="blue",fg="white",bd=5)
        minus5  = Tk.Button(ctrlpanel, text="  <<  ", command=self.minus5,bg="blue",fg="white",bd=5)
        play   = Tk.Button(ctrlpanel, text=" Play ", command=self.OnPlay,bg="blue",fg="white",bd=5)
        stop   = Tk.Button(ctrlpanel, text=" Stop ", command=self.OnStop,bg="blue",fg="white",bd=5)
        Clip_Start = Tk.Button(ctrlpanel, text="Start Clip", command=self.OnClipStart, bg="green",fg="white",bd=5)
        Clip_Clear = Tk.Button(ctrlpanel3, text=" Clear", command=self.OnClipClear,bg="blue",fg="white",bd=5)
        edit = Tk.Button(ctrlpanel, text="/",width=4,bd=5)
        extraButton = Tk.Button(ctrlpanel, text="|||",command=self.task,width=4,bd=5 )
        extraButton1 = Tk.Button(ctrlpanel, text="---",command=self.ScreenShot,width=3,bg="blue",fg="white",bd=5 )


        v1 = StringVar()
        v2 = StringVar()

        S_Time = Entry(ctrlpanel3, textvariable=v1, width=9)
        S_Time.pack(side=LEFT,anchor=W)
        
        Clip_Clear.pack(side=LEFT, padx=(24,0))
        
       
        max_lbl = Label(ctrlpanel3, text="Max").pack(side=LEFT,padx=(80,0))





        self.volume_var = Tk.IntVar()
        self.volslider = Tk.Scale(ctrlpanel3, variable=self.volume_var,width=1.5, command=self.volume_sel,from_=0, to=100, orient=Tk.HORIZONTAL, length=200)
        self.volslider.pack(side=LEFT)


        min_lbl = Label(ctrlpanel3, text="Min").pack(side=LEFT)
        
        












    
        global filename_store,directory_store,fullname
        
        textBox=Text(ctrlpanel3, height=1, width=10)
        textBox.pack(side=LEFT,padx=(110,10))
        
        text_buttonAdd = Button(ctrlpanel3, height=1, width=9, bg="blue",fg="white",bd=5, text="Add button", command=lambda:[Tk.Button(ctrlpanel2,   text=textBox.get("1.0","end-1c"),height=1, width=9, bg="blue",fg="white",bd=5, 
                command=lambda dummy=textBox.get("1.0","end-1c"): self.click_event(dummy)).pack(side="right",anchor=E),os.mkdir(directory_store+'/'+textBox.get("1.0","end-1c")),ButtonNames.append(textBox.get("1.0","end-1c"))])
        text_buttonAdd.pack(side="left",padx=(0,0))
        

        Clip_Start.pack(side=Tk.LEFT,padx=(0,5))
       
        minus5.pack(side=Tk.LEFT,padx=(0,5))
        play.pack(side=Tk.LEFT,padx=(0,0))
        plus5.pack(side=Tk.LEFT,padx=(5,0))
        pause.pack(side=Tk.LEFT,padx=(5,0))
        stop.pack(side=Tk.LEFT,padx=(5,0))
        screenshot.pack(side=Tk.LEFT,padx=(5,0))
        edit.pack(side=Tk.LEFT,padx=(5,0))
        extraButton1.pack(side=Tk.LEFT,padx=(5,0))
        extraButton.pack(side=Tk.LEFT,padx=(5,0))
        
        edit.pack(side=Tk.LEFT,padx=(5,0))
       
       
        
        ctrlpanel2.pack(side=Tk.BOTTOM)
        ctrlpanel3.pack(side=Tk.BOTTOM)
        ctrlpanel.pack(side=Tk.BOTTOM)
        self.Instance = vlc.Instance()
        self.player = self.Instance.media_player_new()
        self.timer = ttkTimer(self.OnTimer, 1.0)
        self.timer.start()
        self.parent.update()
Example #17
0
def XORMultipleImages():
	try:
		global root
		global xorFilesPopup
		global xorString
		global xorOutputDir
		global scrollbar
		global console

		xorString = tk.StringVar()
		xorString.set("")
		xorOutputDir = tk.StringVar()
		xorOutputDir.set("")

		x = root.winfo_x()
		y = root.winfo_y()
		w = root.winfo_width()
		h = root.winfo_height()
		popupWidth = 275
		popupHeight = 100
		xorFilesPopup = tk.Toplevel()
		xorFilesPopup.geometry("%dx%d+%d+%d" % (popupWidth, popupHeight, (x + w/2)-popupWidth/2, (y + h/2)-popupHeight/2))
		xorFilesPopup.transient(root)
		xorFilesPopup.iconbitmap("favicon.ico")
		xorFilesPopup.title("Decrypt/Encrypt texture files")

		# Set widgets
		tk.Label(xorFilesPopup, text="File(s): ").grid(row=1, column=0)
		tk.Entry(xorFilesPopup, textvariable=xorString).grid(row=1, column=1, columnspan=2)
		tk.Button(xorFilesPopup, text="Browse", command=lambda: xorString.set(tkfd.askopenfilenames(parent=xorFilesPopup))).grid(row=1, column=3)

		tk.Label(xorFilesPopup, text="Output Directory: ").grid(row=2, column=0)
		tk.Entry(xorFilesPopup, textvariable=xorOutputDir).grid(row=2, column=1, columnspan=2)
		tk.Button(xorFilesPopup, text="Browse", command=lambda: xorOutputDir.set(tkfd.askdirectory(parent=root))).grid(row=2, column=3)

		proceed = [False] # Python 2 won't let you do assignment in lambdas... unless you're assigning to a list :V

		okayButton = tk.Button(xorFilesPopup, text="Okay", command=lambda: proceed.__setitem__(0,True)).grid(row=3, column=1)

		# Loop the convertFilesPopup dialogue while we wait for the Okay button to be pressed
		while True:
			if xorFilesPopup.winfo_exists() == False:
				raise PopupClosedError()
			elif proceed[0] == True:
				xorFilesPopup.destroy()
				break
			else:
				xorFilesPopup.update_idletasks()
				xorFilesPopup.update()

		fileList = ParseMultipleFilenames(xorString.get())
		outDir = xorOutputDir.get()

		for path in fileList:
			XORTextureFile(path, outDir)

		scrollbar.setNoPreview(None, None)

		lineToBeOutput = str(len(fileList)) + " image(s) exported to " + xorOutputDir.get() + "!\n"
		console.insert(tk.END, lineToBeOutput)

	except PopupClosedError as e:
		pass
	except Exception as e:
		console.insert(tk.END, traceback.format_exc())
Example #18
0
def get_answer(board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt):

    if python_ver == 2:
        import Tkinter as tk
    else:
        import tkinter as tk

    def CPU_exit_3():  # forward declare functions

        CPU_exit_3_()

    def CPU_exit_4():

        CPU_exit_4_()

    def kill_session():
        kill_session_()

    root_get_answer = tk.Tk()

    root_get_answer.chk_state_1 = 1  # declare variables used by TK and enable

    chk_state_1 = 0  # set initial state of check boxes

    global get_answer_val
    get_answer_val = 2  # return get_answer_val, set default to match chk_state_1 default

    l1 = tk.Label(text=board_name,
                  fg="light green",
                  bg="dark green",
                  font="Helvetica 12 bold").grid(row=1)

    l2 = tk.Label(text=cpu_label_txt,
                  fg="light green",
                  bg="dark green",
                  font="Helvetica 16 bold italic").grid(row=2)

    b4 = tk.Checkbutton(text=cpu_a_txt,
                        fg="black",
                        font="Times 20 bold ",
                        variable=chk_state_1,
                        onvalue=1,
                        offvalue=0,
                        command=CPU_exit_3).grid(row=3)

    b5 = tk.Checkbutton(
        text=cpu_b_txt,
        fg="black",
        font="Times 20 bold ",
        variable=chk_state_1,
        onvalue=0,
        offvalue=1,
        command=CPU_exit_4).grid(
            row=4)  # use same variable but inverted so they will track
    b6 = tk.Button(text="CONFIRM",
                   fg="blue",
                   font="Times 20 bold ",
                   command=root_get_answer.destroy).grid(row=5, pady=4)

    b7 = tk.Button(text="CANCEL",
                   fg="red",
                   font="Times 12 bold ",
                   command=kill_session).grid(row=6, pady=4)

    def CPU_exit_3_():
        global get_answer_val
        get_answer_val = 1

    def CPU_exit_4_():
        global get_answer_val
        get_answer_val = 2

    def kill_session_():
        raise SystemExit(0)  # kill everything

    root_get_answer.mainloop()
Example #19
0
    def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.pack()
        self.master.title("")
        self.master.resizable(False, False)
        self.master.tk_setPalette(background='#ececec')

        self.master.protocol('WM_DELETE_WINDOW', self.click_cancel)
        self.master.bind('<Return>', self.click_ok)
        self.master.bind('<Escape>', self.click_cancel)

        x = (self.master.winfo_screenwidth() -
             self.master.winfo_reqwidth()) / 2
        y = (self.master.winfo_screenheight() -
             self.master.winfo_reqheight()) / 3
        self.master.geometry("+{}+{}".format(x, y))

        self.master.config(menu=tk.Menu(self))

        tk.Message(self,
                   text=greeting(),
                   font='System 18 bold',
                   justify='left',
                   aspect=800).pack(pady=(5, 0))
        tk.Message(self,
                   text="Procedures in twiOpinion:",
                   font='System 14 bold',
                   justify='left',
                   aspect=800).pack(pady=(5, 0))

        ## frame last
        f1_5 = tk.Frame(self)
        f1_5.pack(padx=60, pady=(5, 0), anchor='w')

        self.var = tk.IntVar()

        tk.Label(f1_5,
                 text='Select the function you want: ( •̀ .̫ •́ )✧').grid(
                     row=0, column=0, columnspan=9, sticky='w')

        tk.Label(f1_5, font=("Courier", 8), text=' ').grid(row=1,
                                                           column=0,
                                                           columnspan=9,
                                                           sticky='w')

        R1 = tk.Radiobutton(f1_5,
                            text="Step 0. Twitter Accessing Setting",
                            variable=self.var,
                            value=1).grid(row=2, column=0, sticky='w')
        R2 = tk.Radiobutton(f1_5,
                            text="Step 1. Crawling From Twitter",
                            variable=self.var,
                            value=2).grid(row=3, column=0, sticky='w')
        R3 = tk.Radiobutton(f1_5,
                            text="Step 2. Labeling Tweets",
                            variable=self.var,
                            value=3).grid(row=4, column=0, sticky='w')
        R4 = tk.Radiobutton(f1_5,
                            text="Step 3. Learning and Classifying",
                            variable=self.var,
                            value=4).grid(row=5, column=0, sticky='w')
        R5 = tk.Radiobutton(f1_5,
                            text="Step 4. Twitter User Information",
                            variable=self.var,
                            value=5).grid(row=6, column=0, sticky='w')

        tk.Label(f1_5, font=("Courier", 1), text=' ').grid(row=7,
                                                           column=0,
                                                           columnspan=9,
                                                           sticky='w')

        #### get folder
        f1_7 = tk.Frame(self)
        f1_7.pack(padx=25, anchor='w')
        self.path_check = tk.Message(f1_7,
                                     text="  ",
                                     justify='left',
                                     width=380)
        self.path_check.grid(row=0, column=0, columnspan=9, sticky='w')

        #### blue label
        f2 = tk.Frame(self)
        f2.pack(padx=60, anchor='w')
        self.programOutput = tk.StringVar()
        tk.Label(f2,
                 anchor="w",
                 fg="white",
                 bg="blue",
                 textvariable=self.programOutput,
                 width=36).grid(row=1, column=0, sticky='w')
        self.programOutput.set(start_bt_ms)

        fb = tk.Frame(self)
        fb.pack(padx=60, pady=(10, 15), anchor='e')
        self.stb = tk.Button(fb,
                             text='Start !',
                             height=1,
                             width=6,
                             default='active',
                             command=self.click_ok)
        self.stb.pack(side='right')
        self.stb.bind("<Enter>", self.hover_on)
        self.stb.bind("<Leave>", self.hover_off)

        self.stb1_5 = tk.Button(fb,
                                text='Path',
                                height=1,
                                width=6,
                                command=self.click_path)
        self.stb1_5.pack(side='right', padx=10)
        self.stb1_5.bind('<Enter>', self.hover_on1)
        self.stb1_5.bind('<Leave>', self.hover_off)

        self.stb2 = tk.Button(fb,
                              text='Quit...',
                              height=1,
                              width=6,
                              command=self.click_cancel)
        self.stb2.pack(side='right')

        self.pathDisplayed = False
Example #20
0
def plotts(tradingSystem, equity, mEquity, exposure, settings, DATE,
           statistics, returns, marketReturns):
    ''' plots equity curve and calculates trading system statistics

    Args:
        equity (list): list of equity of evaluated trading system.
        mEquity (list): list of equity of each market over the trading days.
        exposure (list): list of positions over the trading days.
        settings (dict): list of settings.
        DATE (list): list of dates corresponding to entries in equity.

    Copyright Quantiacs LLC - March 2015
    '''
    # Initialize selected index of the two dropdown lists
    style.use("ggplot")
    global indx_TradingPerf, indx_Exposure, indx_MarketRet
    cashOffset = 0
    inx = [0]
    inx2 = [0]
    inx3 = [0]
    indx_TradingPerf = 0
    indx_Exposure = 0
    indx_MarketRet = 0

    mRetMarkets = list(settings['markets'])

    try:
        mRetMarkets.remove('CASH')
        cashOffset = 1
    except:
        pass

    settings['markets'].insert(0, 'fundEquity')

    DATEord = []
    lng = len(DATE)
    for i in range(lng):
        DATEord.append(datetime.datetime.strptime(str(DATE[i]), '%Y%m%d'))

    # Prepare all the y-axes
    equityList = np.transpose(np.array(mEquity))

    Long = np.transpose(np.array(exposure))
    Long[Long < 0] = 0
    Long = Long[:, (settings['lookback'] -
                    2):-1]  # Market Exposure lagged by one day

    Short = -np.transpose(np.array(exposure))
    Short[Short < 0] = 0
    Short = Short[:, (settings['lookback'] - 2):-1]

    returnsList = np.transpose(np.array(returns))

    returnLong = np.transpose(np.array(exposure))
    returnLong[returnLong < 0] = 0
    returnLong[returnLong > 0] = 1
    returnLong = np.multiply(
        returnLong[:, (settings['lookback'] - 2):-1],
        returnsList[:, (settings['lookback'] -
                        1):])  # y values for Long Only Equity Curve

    returnShort = -np.transpose(np.array(exposure))
    returnShort[returnShort < 0] = 0
    returnShort[returnShort > 0] = 1
    returnShort = np.multiply(
        returnShort[:, (settings['lookback'] - 2):-1],
        returnsList[:, (settings['lookback'] -
                        1):])  # y values for Short Only Equity Curve

    marketRet = np.transpose(np.array(marketReturns))
    marketRet = marketRet[:, (settings['lookback'] - 1):]
    equityList = equityList[:, (settings['lookback'] -
                                1):]  # y values for all individual markets

    def plot(indx_TradingPerf, indx_Exposure):
        plt.clf()

        Subplot_Equity = plt.subplot2grid((8, 8), (0, 0), colspan=6, rowspan=6)
        Subplot_Exposure = plt.subplot2grid((8, 8), (6, 0),
                                            colspan=6,
                                            rowspan=2,
                                            sharex=Subplot_Equity)
        t = np.array(DATEord)

        if indx_TradingPerf == 0:  # fundEquity selected
            lon = Long.sum(axis=0)
            sho = Short.sum(axis=0)
            y_Long = lon
            y_Short = sho
            if indx_Exposure == 0:  # Long & Short selected
                y_Equity = equity
                Subplot_Equity.plot(t, y_Equity, 'b', linewidth=0.5)
            elif indx_Exposure == 1:  # Long Selected
                y_Equity = settings['budget'] * np.cumprod(1 + returnLong.sum(
                    axis=0))
                Subplot_Equity.plot(t, y_Equity, 'c', linewidth=0.5)
            else:  # Short Selected
                y_Equity = settings['budget'] * np.cumprod(1 + returnShort.sum(
                    axis=0))
                Subplot_Equity.plot(t, y_Equity, 'g', linewidth=0.5)
            statistics = stats(y_Equity)
            Subplot_Equity.plot(
                DATEord[statistics['maxDDBegin']:statistics['maxDDEnd'] + 1],
                y_Equity[statistics['maxDDBegin']:statistics['maxDDEnd'] + 1],
                color='red',
                linewidth=0.5,
                label='Max Drawdown')
            # Subplot_Equity.plot(DATEord[(statistics['maxTimeOffPeakBegin']+1):(statistics['maxTimeOffPeakBegin']+statistics['maxTimeOffPeak']+2)],y_Equity[statistics['maxTimeOffPeakBegin']+1]*np.ones((statistics['maxTimeOffPeak']+1)),'r--',linewidth=2, label = 'Max Time Off Peak')
            if not (np.isnan(statistics['maxTimeOffPeakBegin'])) and not (
                    np.isnan(statistics['maxTimeOffPeak'])):
                Subplot_Equity.plot(
                    DATEord[(statistics['maxTimeOffPeakBegin'] +
                             1):(statistics['maxTimeOffPeakBegin'] +
                                 statistics['maxTimeOffPeak'] + 2)],
                    y_Equity[statistics['maxTimeOffPeakBegin'] + 1] * np.ones(
                        (statistics['maxTimeOffPeak'] + 1)),
                    'r--',
                    linewidth=2,
                    label='Max Time Off Peak')
            Subplot_Exposure.plot(t, y_Long, 'c', linewidth=0.5, label='Long')
            Subplot_Exposure.plot(t,
                                  y_Short,
                                  'g',
                                  linewidth=0.5,
                                  label='Short')
            # Hide the Long(Short) curve in market exposure subplot when Short(Long) is plotted in Equity Curve subplot
            if indx_Exposure == 1:
                Subplot_Exposure.lines.pop(1)
            elif indx_Exposure == 2:
                Subplot_Exposure.lines.pop(0)
            Subplot_Equity.set_yscale('log')
            Subplot_Equity.set_ylabel('Performance (Logarithmic)')
        else:  # individual market selected
            y_Long = Long[indx_TradingPerf - 1]
            y_Short = Short[indx_TradingPerf - 1]
            if indx_Exposure == 0:  # Long & Short Selected
                y_Equity = equityList[indx_TradingPerf - 1]
                Subplot_Equity.plot(t, y_Equity, 'b', linewidth=0.5)
            elif indx_Exposure == 1:  # Long Selected
                y_Equity = np.cumprod(1 + returnLong[indx_TradingPerf - 1])
                Subplot_Equity.plot(t, y_Equity, 'c', linewidth=0.5)
            else:  # Short Selected
                y_Equity = np.cumprod(1 + returnShort[indx_TradingPerf - 1])
                Subplot_Equity.plot(t, y_Equity, 'g', linewidth=0.5)
            statistics = stats(y_Equity)
            Subplot_Exposure.plot(t, y_Long, 'c', linewidth=0.5, label='Long')
            Subplot_Exposure.plot(t,
                                  y_Short,
                                  'g',
                                  linewidth=0.5,
                                  label='Short')
            if indx_Exposure == 1:
                Subplot_Exposure.lines.pop(1)
            elif indx_Exposure == 2:
                Subplot_Exposure.lines.pop(0)
            if np.isnan(statistics['maxDDBegin']) == False:
                Subplot_Equity.plot(
                    DATEord[statistics['maxDDBegin']:statistics['maxDDEnd'] +
                            1],
                    y_Equity[statistics['maxDDBegin']:statistics['maxDDEnd'] +
                             1],
                    color='red',
                    linewidth=0.5,
                    label='Max Drawdown')
                if not (np.isnan(statistics['maxTimeOffPeakBegin'])) and not (
                        np.isnan(statistics['maxTimeOffPeak'])):
                    Subplot_Equity.plot(
                        DATEord[(statistics['maxTimeOffPeakBegin'] +
                                 1):(statistics['maxTimeOffPeakBegin'] +
                                     statistics['maxTimeOffPeak'] + 2)],
                        y_Equity[statistics['maxTimeOffPeakBegin'] + 1] *
                        np.ones((statistics['maxTimeOffPeak'] + 1)),
                        'r--',
                        linewidth=2,
                        label='Max Time Off Peak')
                    # Subplot_Equity.plot(DATEord[(statistics['maxTimeOffPeakBegin']+1):(statistics['maxTimeOffPeakBegin']+statistics['maxTimeOffPeak']+2)],y_Equity[statistics['maxTimeOffPeakBegin']+1]*np.ones((statistics['maxTimeOffPeak']+1)),'r--',linewidth=2, label = 'Max Time Off Peak')
            Subplot_Equity.set_ylabel('Performance')

        statsStr = "Sharpe Ratio = {sharpe:.4f}\nSortino Ratio = {sortino:.4f}\n\nPerformance (%/yr) = {returnYearly:.4f}\nVolatility (%/yr)       = {volaYearly:.4f}\n\nMax Drawdown = {maxDD:.4f}\nMAR Ratio         = {mar:.4f}\n\n Max Time off peak =  {maxTimeOffPeak}\n\n\n\n\n\n".format(
            **statistics)

        Subplot_Equity.autoscale(tight=True)
        Subplot_Exposure.autoscale(tight=True)
        Subplot_Equity.set_title('Trading Performance of %s' %
                                 settings['markets'][indx_TradingPerf])
        Subplot_Equity.get_xaxis().set_visible(False)
        Subplot_Exposure.set_ylabel('Long/Short')
        Subplot_Exposure.set_xlabel('Year')
        Subplot_Equity.legend(bbox_to_anchor=(1.03, 0),
                              loc='lower left',
                              borderaxespad=0.)
        Subplot_Exposure.legend(bbox_to_anchor=(1.03, 0.63),
                                loc='lower left',
                                borderaxespad=0.)

        # Performance Numbers Textbox
        f.text(.72, .58, statsStr)

        plt.gcf().canvas.draw()

    def plot2(indx_Exposure, indx_MarketRet):
        plt.clf()

        MarketReturns = plt.subplot2grid((8, 8), (0, 0), colspan=6, rowspan=8)
        t = np.array(DATEord)

        if indx_Exposure == 2:
            mRet = np.cumprod(1 - marketRet[indx_MarketRet + cashOffset])
        else:
            mRet = np.cumprod(1 + marketRet[indx_MarketRet + cashOffset])

        MarketReturns.plot(t, mRet, 'b', linewidth=0.5)
        statistics = stats(mRet)
        MarketReturns.set_ylabel('Market Returns')

        statsStr = "Sharpe Ratio = {sharpe:.4f}\nSortino Ratio = {sortino:.4f}\n\nPerformance (%/yr) = {returnYearly:.4f}\nVolatility (%/yr)       = {volaYearly:.4f}\n\nMax Drawdown = {maxDD:.4f}\nMAR Ratio         = {mar:.4f}\n\n Max Time off peak =  {maxTimeOffPeak}\n\n\n\n\n\n".format(
            **statistics)

        MarketReturns.autoscale(tight=True)
        MarketReturns.set_title('Market Returns of %s' %
                                mRetMarkets[indx_MarketRet])
        MarketReturns.set_xlabel('Date')

        # Performance Numbers Textbox
        f.text(.72, .58, statsStr)

        plt.gcf().canvas.draw()

    # Callback function for two dropdown lists
    def newselection(event):
        global indx_TradingPerf, indx_Exposure, indx_MarketRet
        value_of_combo = dropdown.current()
        inx.append(value_of_combo)
        indx_TradingPerf = inx[-1]
        indx_MarketRet = -1

        plot(indx_TradingPerf, indx_Exposure)

    def newselection2(event):
        global indx_TradingPerf, indx_Exposure, indx_MarketRet
        value_of_combo2 = dropdown2.current()
        inx2.append(value_of_combo2)
        indx_Exposure = inx2[-1]

        if indx_TradingPerf == -1:
            plot2(indx_Exposure, indx_MarketRet)
        else:
            plot(indx_TradingPerf, indx_Exposure)

    def newselection3(event):
        global indx_TradingPerf, indx_Exposure, indx_MarketRet
        value_of_combo3 = dropdown3.current()
        inx3.append(value_of_combo3)
        indx_MarketRet = inx3[-1]
        indx_TradingPerf = -1

        plot2(indx_Exposure, indx_MarketRet)

    def submit_callback():
        tsfolder, tsName = os.path.split(tradingSystem)
        submit(tradingSystem, tsName[:-3])

    def shutdown_interface():
        TradingUI.eval('::ttk::CancelRepeat')
        # TradingUI.destroy()
        TradingUI.quit()
        TradingUI.destroy()
        # sys.exit()

    # GUI mainloop
    TradingUI = tk.Tk()
    TradingUI.title('Trading System Performance')

    Label_1 = tk.Label(TradingUI, text="Trading Performance:")
    Label_1.grid(row=0, column=0, sticky=tk.EW)

    box_value = tk.StringVar()
    dropdown = ttk.Combobox(TradingUI,
                            textvariable=box_value,
                            state='readonly')
    dropdown['values'] = settings['markets']
    dropdown.grid(row=0, column=1, sticky=tk.EW)
    dropdown.current(0)
    dropdown.bind('<<ComboboxSelected>>', newselection)

    Label_2 = tk.Label(TradingUI, text="Exposure:")
    Label_2.grid(row=0, column=2, sticky=tk.EW)

    box_value2 = tk.StringVar()
    dropdown2 = ttk.Combobox(TradingUI,
                             textvariable=box_value2,
                             state='readonly')
    dropdown2['values'] = ['Long & Short', 'Long', 'Short']
    dropdown2.grid(row=0, column=3, sticky=tk.EW)
    dropdown2.current(0)
    dropdown2.bind('<<ComboboxSelected>>', newselection2)

    Label_3 = tk.Label(TradingUI, text="Market Returns:")
    Label_3.grid(row=0, column=4, sticky=tk.EW)

    box_value3 = tk.StringVar()
    dropdown3 = ttk.Combobox(TradingUI,
                             textvariable=box_value3,
                             state='readonly')
    dropdown3['values'] = mRetMarkets
    dropdown3.grid(row=0, column=5, sticky=tk.EW)
    dropdown3.current(0)
    dropdown3.bind('<<ComboboxSelected>>', newselection3)

    f = plt.figure(figsize=(14, 8))
    canvas = FigureCanvasTkAgg(f, master=TradingUI)

    if updateCheck():
        Text1 = tk.Entry(TradingUI)
        Text1.insert(
            0,
            "Toolbox update available. Run 'pip install --upgrade quantiacsToolbox' from the command line to upgrade."
        )
        Text1.configure(justify='center', state='readonly')

        Text1.grid(row=1, column=0, columnspan=6, sticky=tk.EW)
        canvas.get_tk_widget().grid(row=2,
                                    column=0,
                                    columnspan=6,
                                    sticky=tk.NSEW)

    else:
        canvas.get_tk_widget().grid(row=1,
                                    column=0,
                                    columnspan=6,
                                    rowspan=2,
                                    sticky=tk.NSEW)

    button_submit = tk.Button(TradingUI,
                              text='Submit Trading System',
                              command=submit_callback)
    button_submit.grid(row=4, column=0, columnspan=6, sticky=tk.EW)

    Subplot_Equity = plt.subplot2grid((8, 8), (0, 0), colspan=6, rowspan=6)
    Subplot_Exposure = plt.subplot2grid((8, 8), (6, 0),
                                        colspan=6,
                                        rowspan=2,
                                        sharex=Subplot_Equity)
    t = np.array(DATEord)

    lon = Long.sum(axis=0)
    sho = Short.sum(axis=0)
    y_Long = lon
    y_Short = sho
    y_Equity = equity
    Subplot_Equity.plot(t, y_Equity, 'b', linewidth=0.5)
    statistics = stats(y_Equity)
    Subplot_Equity.plot(
        DATEord[statistics['maxDDBegin']:statistics['maxDDEnd'] + 1],
        y_Equity[statistics['maxDDBegin']:statistics['maxDDEnd'] + 1],
        color='red',
        linewidth=0.5,
        label='Max Drawdown')
    # Subplot_Equity.plot(DATEord[(statistics['maxTimeOffPeakBegin']+1):(statistics['maxTimeOffPeakBegin']+statistics['maxTimeOffPeak']+2)],y_Equity[statistics['maxTimeOffPeakBegin']+1]*np.ones((statistics['maxTimeOffPeak']+1)),'r--',linewidth=2, label = 'Max Time Off Peak')
    if not (np.isnan(statistics['maxTimeOffPeakBegin'])) and not (np.isnan(
            statistics['maxTimeOffPeak'])):
        Subplot_Equity.plot(DATEord[(statistics['maxTimeOffPeakBegin'] +
                                     1):(statistics['maxTimeOffPeakBegin'] +
                                         statistics['maxTimeOffPeak'] + 2)],
                            y_Equity[statistics['maxTimeOffPeakBegin'] + 1] *
                            np.ones((statistics['maxTimeOffPeak'] + 1)),
                            'r--',
                            linewidth=2,
                            label='Max Time Off Peak')
    Subplot_Exposure.plot(t, y_Long, 'c', linewidth=0.5, label='Long')
    Subplot_Exposure.plot(t, y_Short, 'g', linewidth=0.5, label='Short')
    Subplot_Equity.set_yscale('log')
    Subplot_Equity.set_ylabel('Performance (Logarithmic)')

    statsStr = "Sharpe Ratio = {sharpe:.4f}\nSortino Ratio = {sortino:.4f}\n\nPerformance (%/yr) = {returnYearly:.4f}\nVolatility (%/yr)       = {volaYearly:.4f}\n\nMax Drawdown = {maxDD:.4f}\nMAR Ratio         = {mar:.4f}\n\n Max Time off peak =  {maxTimeOffPeak}\n\n\n\n\n\n".format(
        **statistics)

    Subplot_Equity.autoscale(tight=True)
    Subplot_Exposure.autoscale(tight=True)
    Subplot_Equity.set_title('Trading Performance of %s' %
                             settings['markets'][indx_TradingPerf])
    Subplot_Equity.get_xaxis().set_visible(False)
    Subplot_Exposure.set_ylabel('Long/Short')
    Subplot_Exposure.set_xlabel('Year')
    Subplot_Equity.legend(bbox_to_anchor=(1.03, 0),
                          loc='lower left',
                          borderaxespad=0.)
    Subplot_Exposure.legend(bbox_to_anchor=(1.03, 0.63),
                            loc='lower left',
                            borderaxespad=0.)

    plt.gcf().canvas.draw()
    f.text(.72, .58, statsStr)

    TradingUI.protocol("WM_DELETE_WINDOW", shutdown_interface)

    TradingUI.mainloop()
Example #21
0
    password = "******"
    # 获取密码输入框中的密码
    enteredPassword = passwordEntry.get()
    
    # 如果密码正确,显示其结果
    if password == enteredPassword:
        confirmLabel.config(text="Correct")
    # 如果不正确,显示其结果
    else:
        confirmLabel.config(text="Incorrect")
        
# 创建标签控件
passwordLabel = tk.Label(window, text="Password:")

# 创建密码输入框,使用*隐藏字符串
passwordEntry = tk.Entry(window, show="*")   

# 创建按钮
button = tk.Button(window, text="Enter", command=checkPassword)

# 创建标签控件,用来显示密码结果
confirmLabel = tk.Label(window) 

# 显示相关控件
passwordLabel.pack()
passwordEntry.pack()
button.pack()
confirmLabel.pack()

# 主循环
window.mainloop()
Example #22
0
from Tkinter import *
import tkFileDialog
import Bio
from Bio import SeqIO
import sys
if sys.version_info[0] < 3:
    import Tkinter as Tk
else:
    import tkinter as Tk


def browse_file():

    fname = tkFileDialog.askopenfilename(filetypes=(("Template files",
                                                     "*.fasta"), ("All files",
                                                                  "*")))
    print fname
    for seq_record in SeqIO.parse(fname, "fasta"):
        print(seq_record.id)
        print(repr(seq_record.seq))
        print(len(seq_record))


root = Tk.Tk()
root.wm_title("Browser")
broButton = Tk.Button(master=root, text='Browse', width=6, command=browse_file)
broButton.pack(side=Tk.LEFT, padx=2, pady=2)

Tk.mainloop()
Example #23
0
import random
window = Tkinter.Tk()

# greeting text
greeting = Tkinter.Label(window, text="Guess the secret number!")
greeting.pack()
secret = random.randint(1, 100)

# guess entry field
guess = Tkinter.Entry(window)
guess.pack()


# check guess
def check_guess():
    if int(guess.get()) == secret:
        result_text = "CORRECT!"
    elif int(guess.get()) > secret:
        result_text = "WRONG! Your guess is too high."
    else:
        result_text = "WRONG! Your guess is too low."

    tkMessageBox.showinfo("Result", result_text)


# submit button
submit = Tkinter.Button(window, text="Submit",
                        command=check_guess)  # check_guess, not check_guess()
submit.pack()

window.mainloop()
Example #24
0
l7 = ttk.Combobox(values=["Sonido", "Imagen"])
l7.set("No Multimedia")
l7.configure(width=15)
l7.grid(row=6, column=0)
v7 = StringVar()
e7 = Entry(top, textvariable=v7, width=50)
e7.grid(row=6, column=1)

l9 = Label(top, text="Eliminar por id").grid(row=7, column=0)
v9 = StringVar()
e9 = Entry(top, textvariable=v9, width=50)
e9.grid(row=7, column=1)

#boton
b1 = Tkinter.Button(top, text="Insertar", command=insertar).grid(row=4,
                                                                 column=3)
b2 = Tkinter.Button(top, text="Mostrar", command=mostrar).grid(row=5, column=3)
b3 = Tkinter.Button(top, text="Eliminar", command=eliminar).grid(row=7,
                                                                 column=3)
b4 = Tkinter.Button(top, text="Salir", command=salir).grid(row=8, column=3)

#text
scrollbar = Scrollbar(top)
scrollbar.grid(row=8, column=1)
text = Listbox(top, width=50, height=15, yscrollcommand=scrollbar.set)
text.grid(row=8, column=1)
scrollbar.config(command=text.yview)

top.mainloop()
Example #25
0
    def __init__(self, vs, outputPath):
        # store the video stream object and output path, then initialize
        # the most recently read frame, thread for reading frames, and
        # the thread stop event
        mixer.init()
        mixer.music.load('res/buzzzer.mp3')
        self.fgbg = cv2.createBackgroundSubtractorMOG2()
        self.vs = vs
        self.outputPath = outputPath
        self.frame = None
        self.thread = None
        self.stopEvent = None
        self.activity = "No Activity"
        self.sound_running = False
        # initialize the root window and image panel
        self.root = tki.Tk()
        self.panel = None

        # create a button, that when pressed, will take the current
        # frame and save it to file

        # btn = tki.Button(self.root, text="Snapshot!",
        # 	command=self.takeSnapshot)
        # btn.pack(side="bottom", fill="both", expand="yes", padx=10,
        # 	pady=10)

        # start a thread that constantly pools the video sensor for
        # the most recently read frame
        self.stopEvent = threading.Event()
        self.thread = threading.Thread(target=self.videoLoop, args=())
        self.thread.start()

        # set a callback to handle when the window is closed
        self.root.wm_title("XXX  PEACE KEEPER  XXX")
        self.canvas = tki.Canvas(self.root, height=HEIGHT, width=WIDTH)
        self.canvas.pack()

        self.background_image = tki.PhotoImage(file="res/camo.PPM")
        self.background_label = tki.Label(self.root,
                                          image=self.background_image)
        self.background_label.place(relwidth=1, relheight=1)

        self.button_frame = tki.Frame(self.root, bg="#091722", bd=5)
        self.button_frame.place(relx=0.7,
                                rely=0.05,
                                relwidth=0.25,
                                relheight=0.1)

        self.on = tki.Button(self.button_frame,
                             text=" ON ",
                             bg="#54625B",
                             fg="white",
                             highlightbackground="#54625B",
                             command=lambda: self.on_func())
        self.on.place(relwidth=0.5, relheight=1)
        self.off = tki.Button(self.button_frame,
                              text=" OFF ",
                              bg="#54625B",
                              fg="white",
                              highlightbackground="#54625B",
                              command=lambda: self.off_func())
        self.off.place(relx=0.5, relwidth=0.5, relheight=1)

        self.status = tki.Label(self.root,
                                text=" Status ",
                                font=("Courier", 25),
                                bg="#071F2D",
                                fg="white")
        self.status.place(relx=0.7, rely=0.2, relwidth=0.25, relheight=0.1)

        self.stati_frame = tki.Frame(self.root, bg="#091722", bd=5)
        self.stati_frame.place(relx=0.7,
                               rely=0.3,
                               relwidth=0.25,
                               relheight=0.1)

        self.stati_label = tki.Label(self.stati_frame,
                                     bg="#8D978E",
                                     fg="#6BF688",
                                     text="Active",
                                     font=("Courier", 25))
        self.stati_label.place(relwidth=1, relheight=1)

        self.gps_frame = tki.Frame(self.root, bg="#091722")
        self.gps_frame.place(relx=0.05, rely=0.6, relwidth=0.5, relheight=0.3)

        self.gps_label = tki.Label(self.gps_frame,
                                   text="No Activity",
                                   fg="red",
                                   font=("Courier", 40),
                                   bg="#091722")
        self.gps_label.place(relwidth=1, relheight=1)

        self.pos = tki.Label(self.root,
                             text="Position",
                             font=("Courier", 20),
                             bg="#091722",
                             fg="white")
        self.pos.place(relx=0.68, rely=0.55, relwidth=0.3, relheight=0.1)

        self.lat_frame = tki.Frame(self.root, bg="#091722", bd=5)
        self.lat_frame.place(relx=0.68, rely=0.65, relwidth=0.3, relheight=0.1)

        self.lat_label = tki.Label(self.lat_frame,
                                   bg="#7B857B",
                                   text="Latitude: 78.9080980",
                                   font=("Courier", 25))
        self.lat_label.place(relwidth=1, relheight=1)

        self.lon_frame = tki.Frame(self.root, bg="#091722", bd=5)
        self.lon_frame.place(relx=0.68,
                             rely=0.745,
                             relwidth=0.3,
                             relheight=0.1)

        self.lon_label = tki.Label(self.lon_frame,
                                   bg="#7B857B",
                                   text="Longitude: 67.0989080",
                                   font=("Courier", 25))
        self.lon_label.place(relwidth=1, relheight=1)

        self.root.wm_protocol("WM_DELETE_WINDOW", self.onClose)
Example #26
0
    def draw(self, show=True, filename=None, update=False, usecoords=False):
        """Create a 2D depiction of the molecule.

        Optional parameters:
          show -- display on screen (default is True)
          filename -- write to file (default is None)
          update -- update the coordinates of the atoms to those
                    determined by the structure diagram generator
                    (default is False)
          usecoords -- don't calculate 2D coordinates, just use
                       the current coordinates (default is False)

        Tkinter and Python Imaging Library are required for image display.
        """
        if not "png2" in outformats:
            errormessage = ("PNG output format not found. You should compile "
                            "Open Babel with PNG support. See installation "
                            "instructions for more information.")
            raise ImportError(errormessage)

        # Need to copy to avoid removing hydrogens from self
        workingmol = Molecule(ob.OBMol(self.OBMol))
        workingmol.removeh()

        if not usecoords:
            _operations['gen2D'].Do(workingmol.OBMol)
        if update == True:
            if workingmol.OBMol.NumAtoms() != self.OBMol.NumAtoms():
                errormessage = (
                    "It is not possible to update the original molecule "
                    "with the calculated coordinates, as the original "
                    "molecule contains explicit hydrogens for which no "
                    "coordinates have been calculated.")
                raise RunTimeError(errormessage)
            else:
                for i in range(workingmol.OBMol.NumAtoms()):
                    self.OBMol.GetAtom(i + 1).SetVector(
                        workingmol.OBMol.GetAtom(i + 1).GetVector())

        if filename:
            filedes = None
        else:
            filedes, filename = tempfile.mkstemp()

        workingmol.write("png2", filename=filename, overwrite=True)

        if show:
            if not tk:
                errormessage = ("Tkinter or Python Imaging "
                                "Library not found, but is required for image "
                                "display. See installation instructions for "
                                "more information.")
                raise ImportError(errormessage)
            root = tk.Tk()
            root.title((hasattr(self, "title") and self.title)
                       or self.__str__().rstrip())
            frame = tk.Frame(root, colormap="new", visual='truecolor').pack()
            image = PIL.open(filename)
            imagedata = piltk.PhotoImage(image)
            label = tk.Label(frame, image=imagedata).pack()
            quitbutton = tk.Button(root, text="Close",
                                   command=root.destroy).pack(fill=tk.X)
            root.mainloop()
        if filedes:
            os.close(filedes)
            os.remove(filename)
Example #27
0
    def __init__(self, engine):
        Tkinter.Toplevel.__init__(self, share.gui)
        gui.__init__(self, 'TK gui', {}, engine)
        self.name = "<tkgui>"  # for checking sys.stdout.name
        self.genlist = 0
        self.frame = Tkinter.Frame(self)
        self.frame.pack(side='bottom', expand="yes", anchor="n", fill='both')
        self.windowBrain = 0
        self.lastRun = 0
        self.lasttime = 0
        self.brainTreeWindow = None
        self.robotTreeWindow = None
        self.update_interval = 100
        self.update_interval_detail = 1.0
        self.lastButtonUpdate = 0
        self.printBuffer = []
        self.maxBufferSize = 50000  # 50k characters in buffer
        #set to 0 for infinite
        #store the gui structure in something nice insted of python code

        menu = [
            ('File', [['New brain...', self.newBrain], None,
                      ['Editor', self.editor],
                      ['Expression Watcher', self.makeWatcher],
                      ['Save current config as...', self.saveConfig], None,
                      ['Exit', self.cleanup]]),
            ('Window', [
                ['Open all device windows', self.makeWindows],
                None,
                ['Fast Update 10/sec', self.fastUpdate],
                ['Medium Update 3/sec', self.mediumUpdate],
                ['Slow Update 1/sec', self.slowUpdate],
                None,
                ['Clear Messages', self.clearMessages],
                ['Send Messages to Window', self.redirectToWindow],
                ['Send Messages to Terminal', self.redirectToTerminal],
            ]),
            (
                'Load',
                [
                    ['Server...', self.loadSim],
                    ['Robot...', self.loadRobot],
                    ['Devices...', self.loadDevice],
                    ['Brain...', self.loadBrain],
                    #['Built-in Devices', None],
                ]),
            ('Robot', [
                ['Joystick', self.joystick],
                ['View', self.makeRobotTree],
                None,
                ['Forward', self.stepForward],
                ['Back', self.stepBack],
                ['Left', self.stepLeft],
                ['Right', self.stepRight],
                None,
                ['Stop Rotate', self.stopRotate],
                ['Stop Translate', self.stopTranslate],
                ['Stop All', self.stopEngine],
                None,
                ['Unload robot', self.freeRobot],
                None,
                ['Update', self.update],
            ]),
            ('Brain', [
                ['Watch', self.openBrainWindow],
                ['View', self.makeBrainTree],
                None,
                ['Unload brain', self.freeBrain],
            ]),
            ('Help', [
                ['Help', self.help],
                ['About', self.about],
            ])
        ]

        self.var = Tkinter.StringVar()
        self.currentDeviceList = []
        button1 = [
            ('Step', self.stepEngine),
            ('Run', self.runEngine),
            ('Stop', self.stopEngine),
            ('Reload Brain', self.resetEngine),
        ]

        # create menu
        self.mBar = Tkinter.Frame(self.frame,
                                  relief=Tkinter.RAISED,
                                  borderwidth=2)
        self.mBar.pack(fill=Tkinter.X)
        self.goButtons = {}
        self.menuButtons = {}
        for entry in menu:
            self.mBar.tk_menuBar(self.makeMenu(self.mBar, entry[0], entry[1]))

        #self.menuButtons["Built-in Devices"] = Tkinter.Menubutton(self.mBar,text="Test",underline=0)

        self.frame.winfo_toplevel().title("pyrobot@%s" % os.getenv('HOSTNAME'))
        self.frame.winfo_toplevel().protocol('WM_DELETE_WINDOW', self.cleanup)

        # create a command text area:
        self.makeCommandArea()
        # Display:
        self.loadables = [
            ('button', 'Server:', self.loadSim, self.editWorld,
             0),  # 0 = False
            ('button', 'Robot:', self.loadRobot, self.editRobot,
             self.makeRobotTree),
            ('picklist', 'Devices:', self.loadDevice, self.editDevice,
             self.viewDevice),
            ('button', 'Brain:', self.loadBrain, self.editBrain,
             self.makeBrainTree),
        ]
        self.buttonArea = {}
        self.textArea = {}
        for item in self.loadables:
            self.makeRow(item)

        self.buttonArea["Robot:"]["state"] = 'normal'
        self.buttonArea["Server:"]["state"] = 'normal'
        ## ----------------------------------
        toolbar = Tkinter.Frame(self.frame)
        for b in button1:
            self.goButtons[b[0]] = Tkinter.Button(toolbar,
                                                  text=b[0],
                                                  command=b[1])
            self.goButtons[b[0]].pack(side=Tkinter.LEFT,
                                      padx=2,
                                      pady=2,
                                      fill=Tkinter.X,
                                      expand="yes",
                                      anchor="n")
        toolbar.pack(side=Tkinter.TOP, anchor="n", fill='x', expand="no")
        ## ----------------------------------
        self.makeRow(('status', 'Pose:', '', '', 0))  # 0 = False
        ## ----------------------------------
        self.textframe = Tkinter.Frame(self.frame)
        self.textframe.pack(side="top", expand="yes", fill="both")
        # could get width from config
        self.status = Tkinter.Text(self.textframe,
                                   width=60,
                                   height=10,
                                   state='disabled',
                                   wrap='word',
                                   bg="white")
        self.scrollbar = Tkinter.Scrollbar(self.textframe,
                                           command=self.status.yview)
        self.status.configure(yscroll=self.scrollbar.set)
        # for displaying fonts, colors, etc.: -------------------
        self.status.tag_config("red", foreground="red")
        self.status.tag_config("black", foreground="black")
        self.status.tag_config("green", foreground="green")
        self.status.tag_config("blue", foreground="blue")
        # --------------------------------------------------------
        self.scrollbar.pack(side="right", expand="no", fill="y")
        self.status.pack(side="top", expand="yes", fill="both")
        self.textframe.pack(side="top", fill="both")
        self.redirectToWindow()
        #self.tk_focusFollowsMouse()
        self.commandEntry.focus_force()
        self.inform("Pyrobot Version " + version() + ": Ready...")
        self.updateDeviceList(select=0)
Example #28
0
import Tkinter as tk
    

def write_slogan():
    print("Tkinter is easy to use!")

root = tk.Tk()
frame = tk.Frame(root)
frame.pack()

button = tk.Button(frame, 
                   text="QUIT", 
                   fg="red",
                   command=quit)
button.pack(side=tk.LEFT)
slogan = tk.Button(frame,
                   text="Hello",
                   command=write_slogan)
slogan.pack(side=tk.LEFT)

root.mainloop()
Example #29
0
    def run(self):
        #Build window
        self.root = Tkinter.Tk()

        self.root.title('MidiPresenter')

        self.root.protocol("WM_DELETE_WINDOW", self.closeCallback)

        frame = Tkinter.Frame(self.root)
        frame.grid(column=0,
                   row=0,
                   sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)

        #Build buttons
        #Toggle button, switches between Active/Inacive state, call toggleCallback with every press
        self.toggle = Tkinter.Button(frame, command=self.toggleCallback)
        self.toggle.grid(row=1, column=1, sticky=Tkinter.E + Tkinter.N)

        #Quit button, call closeCallback with every press
        self.button = Tkinter.Button(frame,
                                     text="QUIT",
                                     command=self.closeCallback)
        self.button.grid(row=1, column=2, sticky=Tkinter.W)

        #Create a frame to house a scrollbar and Text area.
        frameA = Tkinter.Frame(frame, relief=Tkinter.GROOVE, bd=1)
        frameA.grid(row=2,
                    column=1,
                    columnspan=2,
                    sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)

        #Create a scrollbar and Text area.
        scrollbar = Tkinter.Scrollbar(frameA, orient=Tkinter.VERTICAL)
        self.mainLabel = Tkinter.Listbox(frameA,
                                         height=5,
                                         width=50,
                                         selectmode=Tkinter.EXTENDED)

        #Add the scrollbar and text area to the layout.
        scrollbar.pack(side=Tkinter.RIGHT, fill=Tkinter.Y)
        self.mainLabel.pack(side=Tkinter.LEFT,
                            fill=Tkinter.BOTH,
                            expand=Tkinter.YES)

        #Assign the scrollbar and text area to each other.
        scrollbar.configure(command=self.mainLabel.yview)
        self.mainLabel.configure(yscrollcommand=scrollbar.set)

        #Allow for window resizing.
        self.root.rowconfigure(0, weight=1)
        frame.rowconfigure(2, weight=1)
        self.root.columnconfigure(0, weight=1)
        frame.columnconfigure(1, weight=1)
        frame.columnconfigure(2, weight=1)

        #Add select and double click listeners
        self.mainLabel.bind('<<ListboxSelect>>', self.onselect)
        self.mainLabel.bind('<Double-Button-1>', self.ondouble)

        #Build state
        self.activate()

        self.checkMessageQueue()
        self.isDialogOpen = False

        #Get started
        self.root.mainloop()
Example #30
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("638x723+759+98")
        top.minsize(120, 1)
        top.maxsize(3844, 1061)
        top.resizable(0, 0)
        top.title("JPKv7 Sender")
        top.iconbitmap('assets/ico.ico')
        top.configure(background="#d9d9d9")

        self.Labelframe1 = tk.LabelFrame(top)
        self.Labelframe1.place(relx=0.016,
                               rely=0.014,
                               relheight=0.159,
                               relwidth=0.962)
        self.Labelframe1.configure(relief='groove')
        self.Labelframe1.configure(foreground="black")
        self.Labelframe1.configure(text='''Krok 1:''')
        self.Labelframe1.configure(background="#d9d9d9")

        self.Button1 = tk.Button(self.Labelframe1, command=self.load_jpk_file)
        self.Button1.place(relx=0.782,
                           rely=0.174,
                           height=34,
                           width=117,
                           bordermode='ignore')
        self.Button1.configure(activebackground="#ececec")
        self.Button1.configure(activeforeground="#000000")
        self.Button1.configure(background="#d9d9d9")
        self.Button1.configure(disabledforeground="#a3a3a3")
        self.Button1.configure(foreground="#000000")
        self.Button1.configure(highlightbackground="#d9d9d9")
        self.Button1.configure(highlightcolor="black")
        self.Button1.configure(pady="0")
        self.Button1.configure(text='''Wybierz JPK''')

        self.Button2 = tk.Button(self.Labelframe1,
                                 command=self.generate_initial_upload)
        self.Button2.place(relx=0.782,
                           rely=0.609,
                           height=34,
                           width=117,
                           bordermode='ignore')
        self.Button2.configure(activebackground="#ececec")
        self.Button2.configure(activeforeground="#000000")
        self.Button2.configure(state='disabled')
        self.Button2.configure(background="#d9d9d9")
        self.Button2.configure(disabledforeground="#a3a3a3")
        self.Button2.configure(foreground="#000000")
        self.Button2.configure(highlightbackground="#d9d9d9")
        self.Button2.configure(highlightcolor="black")
        self.Button2.configure(pady="0")
        self.Button2.configure(text='''Generuj''')

        self.Label1 = tk.Label(self.Labelframe1)
        self.Label1.place(relx=0.016,
                          rely=0.174,
                          height=21,
                          width=78,
                          bordermode='ignore')
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(text='''Wybrany plik:''')

        self.Label2 = tk.Label(self.Labelframe1)
        self.Label2.place(relx=0.016,
                          rely=0.348,
                          height=21,
                          width=400,
                          bordermode='ignore')
        self.Label2.configure(background="#d9d9d9")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(text='''Brak pliku''')

        self.Labelframe2 = tk.LabelFrame(top)
        self.Labelframe2.place(relx=0.016,
                               rely=0.194,
                               relheight=0.119,
                               relwidth=0.956)
        self.Labelframe2.configure(relief='groove')
        self.Labelframe2.configure(foreground="black")
        self.Labelframe2.configure(text='''Krok 2:''')
        self.Labelframe2.configure(background="#d9d9d9")

        self.Label3 = tk.Label(self.Labelframe2)
        self.Label3.place(relx=0.016,
                          rely=0.233,
                          height=61,
                          width=594,
                          bordermode='ignore')
        self.Label3.configure(background="#d9d9d9")
        self.Label3.configure(disabledforeground="#a3a3a3")
        self.Label3.configure(foreground="#000000")
        self.Label3.configure(
            text=
            '''Podpisz wygenerowany plik podpisem kwalifikowanym lub profilem zaufanym.'''
        )

        self.Labelframe3 = tk.LabelFrame(top)
        self.Labelframe3.place(relx=0.016,
                               rely=0.318,
                               relheight=0.145,
                               relwidth=0.956)
        self.Labelframe3.configure(relief='groove')
        self.Labelframe3.configure(foreground="black")
        self.Labelframe3.configure(text='''Krok 3:''')
        self.Labelframe3.configure(background="#d9d9d9")

        self.Button3 = tk.Button(self.Labelframe3,
                                 command=self.load_signed_file)
        self.Button3.place(relx=0.721,
                           rely=0.19,
                           height=34,
                           width=153,
                           bordermode='ignore')
        self.Button3.configure(activebackground="#ececec")
        self.Button3.configure(activeforeground="#000000")
        self.Button3.configure(background="#d9d9d9")
        self.Button3.configure(disabledforeground="#a3a3a3")
        self.Button3.configure(foreground="#000000")
        self.Button3.configure(highlightbackground="#d9d9d9")
        self.Button3.configure(highlightcolor="black")
        self.Button3.configure(pady="0")
        self.Button3.configure(text='''Wybierz podpisany plik''')

        self.Button3_1 = tk.Button(self.Labelframe3, command=self.send_jpk)
        self.Button3_1.place(relx=0.721,
                             rely=0.571,
                             height=34,
                             width=153,
                             bordermode='ignore')
        self.Button3_1.configure(activebackground="#ececec")
        self.Button3_1.configure(activeforeground="#000000")
        self.Button3_1.configure(background="#d9d9d9")
        self.Button3_1.configure(state='disabled')
        self.Button3_1.configure(disabledforeground="#a3a3a3")
        self.Button3_1.configure(foreground="#000000")
        self.Button3_1.configure(highlightbackground="#d9d9d9")
        self.Button3_1.configure(highlightcolor="black")
        self.Button3_1.configure(pady="0")
        self.Button3_1.configure(text='''Wyślij do MF''')

        self.Label4 = tk.Label(self.Labelframe3)
        self.Label4.place(relx=0.016,
                          rely=0.19,
                          height=31,
                          width=84,
                          bordermode='ignore')
        self.Label4.configure(background="#d9d9d9")
        self.Label4.configure(disabledforeground="#a3a3a3")
        self.Label4.configure(foreground="#000000")
        self.Label4.configure(text='''Wybrany plik:''')

        self.Label5 = tk.Label(self.Labelframe3)
        self.Label5.place(relx=0.016,
                          rely=0.476,
                          height=21,
                          width=400,
                          bordermode='ignore')
        self.Label5.configure(background="#d9d9d9")
        self.Label5.configure(disabledforeground="#a3a3a3")
        self.Label5.configure(foreground="#000000")
        self.Label5.configure(text="Brak pliku")

        self.Button3_3 = tk.Button(self.Labelframe3)
        self.Button3_3.place(relx=0.216,
                             rely=3.857,
                             height=101,
                             width=253,
                             bordermode='ignore')
        self.Button3_3.configure(activebackground="#ececec")
        self.Button3_3.configure(activeforeground="#000000")
        self.Button3_3.configure(background="#d9d9d9")
        self.Button3_3.configure(disabledforeground="#a3a3a3")
        self.Button3_3.configure(foreground="#000000")
        self.Button3_3.configure(highlightbackground="#d9d9d9")
        self.Button3_3.configure(highlightcolor="black")
        self.Button3_3.configure(pady="0")
        self.Button3_3.configure(text='''Wybierz podpisany plik''')

        self.Labelframe4 = tk.LabelFrame(top)
        self.Labelframe4.place(relx=0.016,
                               rely=0.47,
                               relheight=0.214,
                               relwidth=0.956)
        self.Labelframe4.configure(relief='groove')
        self.Labelframe4.configure(foreground="black")
        self.Labelframe4.configure(text='''Krok 4:''')
        self.Labelframe4.configure(background="#d9d9d9")

        self.Listbox1 = tk.Listbox(self.Labelframe4)
        self.Listbox1.place(relx=0.016,
                            rely=0.129,
                            relheight=0.568,
                            relwidth=0.564,
                            bordermode='ignore')
        self.Listbox1.configure(background="white")
        self.Listbox1.configure(disabledforeground="#a3a3a3")
        self.Listbox1.configure(font="TkFixedFont")
        self.Listbox1.configure(foreground="#000000")
        self.load_initial_data()

        self.Button4 = tk.Button(self.Labelframe4, command=self.get_status_jpk)
        self.Button4.place(relx=0.721,
                           rely=0.135,
                           height=34,
                           width=157,
                           bordermode='ignore')
        self.Button4.configure(activebackground="#ececec")
        self.Button4.configure(activeforeground="#000000")
        self.Button4.configure(background="#d9d9d9")
        self.Button4.configure(disabledforeground="#a3a3a3")
        self.Button4.configure(foreground="#000000")
        self.Button4.configure(highlightbackground="#d9d9d9")
        self.Button4.configure(highlightcolor="black")
        self.Button4.configure(pady="0")
        self.Button4.configure(text='''Sprawdz''')

        self.Button4_4 = tk.Button(self.Labelframe4)
        self.Button4_4.place(relx=0.721,
                             rely=0.484,
                             height=34,
                             width=157,
                             bordermode='ignore')
        self.Button4_4.configure(activebackground="#ececec")
        self.Button4_4.configure(activeforeground="#000000")
        self.Button4_4.configure(background="#d9d9d9")
        self.Button4_4.configure(disabledforeground="#a3a3a3")
        self.Button4_4.configure(foreground="#000000")
        self.Button4_4.configure(highlightbackground="#d9d9d9")
        self.Button4_4.configure(highlightcolor="black")
        self.Button4_4.configure(pady="0")
        self.Button4_4.configure(text='''Pobierz UPO''')

        self.Button5 = tk.Button(self.Labelframe4, command=self.removeListBox)
        self.Button5.place(relx=0.59,
                           rely=0.129,
                           height=24,
                           width=38,
                           bordermode='ignore')
        self.Button5.configure(activebackground="#ececec")
        self.Button5.configure(activeforeground="#000000")
        self.Button5.configure(background="#d9d9d9")
        self.Button5.configure(disabledforeground="#a3a3a3")
        self.Button5.configure(foreground="#000000")
        self.Button5.configure(highlightbackground="#d9d9d9")
        self.Button5.configure(highlightcolor="black")
        self.Button5.configure(pady="0")
        self.Button5.configure(text='''Usuń''')

        self.Button6 = tk.Button(self.Labelframe4,
                                 command=self.add_item_ListBox)
        self.Button6.place(relx=0.508,
                           rely=0.774,
                           height=24,
                           width=42,
                           bordermode='ignore')
        self.Button6.configure(activebackground="#ececec")
        self.Button6.configure(activeforeground="#000000")
        self.Button6.configure(background="#d9d9d9")
        self.Button6.configure(disabledforeground="#a3a3a3")
        self.Button6.configure(foreground="#000000")
        self.Button6.configure(highlightbackground="#d9d9d9")
        self.Button6.configure(highlightcolor="black")
        self.Button6.configure(pady="0")
        self.Button6.configure(text='''Dodaj''')

        self.Entry = tk.Entry(self.Labelframe4)
        self.Entry.place(relx=0.033,
                         rely=0.774,
                         height=20,
                         relwidth=0.466,
                         bordermode='ignore')
        self.Entry.configure(background="white")
        self.Entry.configure(disabledforeground="#a3a3a3")
        self.Entry.configure(font="TkFixedFont")
        self.Entry.configure(foreground="#000000")
        self.Entry.configure(insertbackground="black")

        self.Scrolledtext = ScrolledText(top)
        self.Scrolledtext.place(relx=0.016,
                                rely=0.705,
                                relheight=0.284,
                                relwidth=0.964)
        self.Scrolledtext.configure(background="white")
        self.Scrolledtext.configure(font="TkTextFont")
        self.Scrolledtext.configure(foreground="black")
        self.Scrolledtext.configure(highlightbackground="#d9d9d9")
        self.Scrolledtext.configure(highlightcolor="black")
        self.Scrolledtext.configure(insertbackground="black")
        self.Scrolledtext.configure(insertborderwidth="3")
        self.Scrolledtext.configure(selectbackground="blue")
        self.Scrolledtext.configure(selectforeground="white")
        self.Scrolledtext.configure(wrap="none")

        self.jpk_file = None
        self.signed_file = None