Esempio n. 1
0
        def __init__(self, master,title=None,args=None):

                self.master = master
                self.args = args
                self.name = title
                master.title("Startup interface for %s" % title)
                self.arguments = dict()

                style = Style()
                style.configure(".",background="lightgrey")
                
                labelStyle = Style()
                labelStyle.configure("TLabel", background="lightgrey")
                buttonStyle = Style()
                buttonStyle.configure("TButton", background = "lightgrey")
                chkbuttonStyle = Style()
                chkbuttonStyle.configure("TCheckbutton", background = "lightgrey")
                rbuttonStyle = Style()
                rbuttonStyle.configure("TRadiobutton", background = "lightgrey")

                row = 0
                column = 0
                
                # Input edge file
                self.inEdgeLabel = Label(master, text = "Input edge file")
                self.inEdgeLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.inEdgeFile = StringVar()
                if self.args.input_edge_file:
                        self.inEdgeFile.set(self.args.input_edge_file)
                self.inEdgeEntry = Entry(master, width = WIDTH, textvariable = self.inEdgeFile)
                column += 1
                self.inEdgeEntry.grid(row=row,column=column, padx=3)
                self.inEdgeSelect = Button(master, text = "Select", command = lambda: self.setOutputFiles(IN=self.inEdgeFile,TWIN=self.outTwinFile,TWINCOMP=self.twinCompFile))
                column += 1
                self.inEdgeSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "required")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText1 = "Edge file for input graph (two columns, tab-delimited)."
                self.inEdgeTip = CreateToolTip(self.inEdgeEntry, helpText1)
                ##
                row += 1
                column = 0

                # Output twin file
                self.outTwinLabel = Label(master, text = "Output twin file")
                self.outTwinLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.outTwinFile = StringVar()
                if self.args.o:
                        self.outTwinFile.set(self.args.o)
                self.outTwinEntry = Entry(master, width = WIDTH, textvariable = self.outTwinFile)
                column += 1
                self.outTwinEntry.grid(row=row,column=column, padx=3)
                self.outTwinSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.outTwinFile))
                column += 1
                self.outTwinSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "required")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText2 = "Links a nodeID to its twin class ID (two columns, tab-delimited)."
                self.outTwinTip = CreateToolTip(self.outTwinEntry, helpText2)
                ##
                row += 1
                column = 0

                # Twin component file
                self.twinCompLabel = Label(master, text = "Twin component file ")
                self.twinCompLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.twinCompFile = StringVar()
                if self.args.c:
                        self.twinCompFile.set(self.args.c)
                self.twinCompEntry = Entry(master, width = WIDTH, textvariable = self.twinCompFile)
                column += 1
                self.twinCompEntry.grid(row=row,column=column, padx=3)
                self.twinCompSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.twinCompFile))
                column += 1
                self.twinCompSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "optional")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText3 = "Links a nodeID and its neighbours to the twin class ID.\nThis is usually an overlapping clustering."
                self.twinCompTip = CreateToolTip(self.twinCompEntry, helpText3)
                ##
                row += 1
                column = 0

                # Populate outFiles if edge file given
                if self.args.input_edge_file:
                        inFile = os.path.split(self.args.input_edge_file)[1]
                        inRad = inFile.split(".")[0]
                        twin = inRad+".twins"
                        twinComp = inRad+".twin_comp"
                        self.outTwinFile.set(twin)
                        self.twinCompFile.set(twinComp)

                # Partiteness options
                self.inNodeLabel = Label(master, text = "Partitneness")
                self.inNodeLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                MODES = [("Unipartite", "1"),("Bipartite", "2"),]
                self.inNodeType = StringVar()
                self.v = StringVar()
                if str(self.args.n) == '1' or str(self.args.n) == '2':
                        self.v.set(self.args.n) # initialize at bipartite
                elif self.args.n:
                        self.v.set("m")
                        self.inNodeType.set(self.args.n)
                rbFrame = Frame(master)  # create subframe for radiobuttons
                for text,mode in MODES:
                        b = Radiobutton(rbFrame, text=text, variable=self.v, value=mode, command = lambda: self.inNodeType.set(''))
                        # tip
                        CreateToolTip(b,"Select if graph is %s" % text.lower())
                        ##
                        b.pack(side="left", fill=None, expand=False, padx=3)
                b = Radiobutton(rbFrame, text="Multipartite", variable=self.v, value="m", command = lambda: self.openFile(var=self.inNodeType))
                CreateToolTip(b,"Select if graph is multipartite.\nThis will open a select box for the node type file.")
                b.pack(side="left", fill=None, expand=False, padx=3)                        
                rbFrame.grid(row=row,column=column, padx=3)
                row += 1
                column = 0
                self.inNodeEntry = Entry(master, width = WIDTH, textvariable = self.inNodeType, validate='focusin',validatecommand = lambda: self.v.set("m"))
                CreateToolTip(self.inNodeEntry,"""Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite".""")
                column += 1
                self.inNodeEntry.grid(row=row,column=column, padx=3)
                self.inNodeSelect = Button(master, text = "Select", command = lambda: self.openFile2(var=self.inNodeType,var2=self.v,value="m")) # reset value to "multipartite" when type file is chosen.
                column += 1
                self.inNodeSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "for multipartite")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                CreateToolTip(self.inNodeSelect,"""Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite".""")
                row += 1
                column = 0

                # unilat
                self.twinSelectLabel = Label(master, text = "Restrict to node types")
                self.twinSelectLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                self.unilat = StringVar()
                if self.args.u:
                        self.unilat.set(self.args.u)
                self.twinSelectEntry = Entry(master, width = WIDTH, textvariable = self.unilat)
                self.twinSelectEntry.grid(row=row,column=column, padx=3)
                column += 2
                self.optionLabel2 = Label(master, text = "optional (comma-separated)")
                self.optionLabel2.grid(row=row,column=column, padx=3)
                CreateToolTip(self.twinSelectEntry,"Computes twins for nodes of specified types only.")
                row += 1
                column = 0

                # Min support 
                self.minsuppLabel = Label(master, text = "Minimum support")
                self.minsuppLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                self.minsupp = StringVar()
                if self.args.thr:
                        self.minsupp.set(self.args.thr)
                self.minsuppEntry = Entry(master, width = WIDTH, textvariable = self.minsupp)
                self.minsuppEntry.grid(row=row,column=column, padx=3)
                column += 2
                self.optionLabel2 = Label(master, text = "optional")
                self.optionLabel2.grid(row=row,column=column, padx=3,sticky=W)
                CreateToolTip(self.minsuppEntry,"Returns twins only if their neighbourhood has at least this number of elements.")
                row += 1
                column = 0

                # min size
                self.minsizeLabel = Label(master, text = "Minimum twin size")
                self.minsizeLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                self.minsize = StringVar()
                if self.args.M:
                        self.minsize.set(self.args.M)
                self.minsizeEntry = Entry(master, width = WIDTH, textvariable = self.minsize)
                self.minsizeEntry.grid(row=row,column=column, padx=3)
                column += 2
                self.optionLabel2 = Label(master, text = "optional")
                self.optionLabel2.grid(row=row,column=column, padx=3,sticky=W)
                CreateToolTip(self.minsizeEntry,"Returns twins only if they have at least this number of elements.")
                row += 1
                column = 0

                # Log
                self.optionLabel = Label(master, text = "Log file")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.l = StringVar()
                try:
                        log = self.args.l.name.strip("(<,>")
                except:
                        log = log
                self.l.set(log)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.l)
                self.optionEntry.grid(row=row,column=1, padx=3)
                row += 2

                cbFrame = Frame(master)  # create subframe for command buttons

                self.run_button = Button(cbFrame, text="Run", command=self.run)
                self.run_button.grid(row=row,column=0,padx=12)
                
                self.close_button = Button(cbFrame, text="Close", command=self.Quit)
                self.close_button.grid(row=row,column=1,padx=12)

                cbFrame.grid(row=row,column=1,columnspan=2,sticky=E+W)

                helpText = detect_twins.processArgs().format_help()
                self.helpbutton = Button(master, text="Help", command = lambda: HelpWindow(text=helpText,name=self.name))
                self.helpbutton.grid(row=row,column=2,sticky=W,padx=3)
    def build(self):
        self.rbs = []
        self.rbs1 = []
        self.lF0 = lF0 = LabelFrame(self.fr, text='Widget and Themes')
        lF0.grid(row=0, column=0, sticky='nw')
        self.fr1 = fr1 = Frame(lF0)
        fr1.grid(row=0, column=0, sticky='nw')
        # create check box to select reverse selection order
        self.lF12 = lF12 = LabelFrame(fr1, text='Select Widget before Theme')
        lF12.grid(row=0, column=0, sticky='nw')
        self.ord = ord = IntVar()
        ord.set(0)
        cbut3 = Checkbutton(lF12,
                            text='Reverse selection order',
                            variable=ord,
                            command=self.selord)
        cbut3.grid(row=0, column=0, padx=5, pady=5)
        cbut3.state(['!selected'])

        # create a Combobox to choose widgets
        widget_sel = [
            'Button', 'Checkbutton', 'Combobox', 'Entry', 'Frame', 'Label',
            'LabelFrame', 'Menubutton', 'Notebook', 'PanedWindow',
            'Progressbar', 'Radiobutton', 'Scale', 'Scrollbar', 'Separator',
            'Sizegrip', 'Treeview'
        ]
        ord = self.ord

        self.lf6 = LabelFrame(self.fr1,
                              text='Select Widget',
                              style="RoundedFrame",
                              padding=(10, 1, 10, 10))
        self.lf6.grid(row=1, column=0, sticky='nw')

        self.lf6.state([("focus" if self.ord.get() == 0 else "!focus")])
        self.widget_value = StringVar()
        self.cb = Combobox(
            self.lf6,
            values=widget_sel,
            textvariable=self.widget_value,
            state=('disabled' if self.ord.get() == 1 else 'active'))
        self.cb.grid(row=0, column=0, padx=5, pady=5, sticky='nw')
        self.cb.bind('<<ComboboxSelected>>', self.enabled)

        # create a Radio Buttons to choose orientation
        fr2 = Frame(self.lF0)
        fr2.grid(row=0, column=1, sticky='nw')
        self.lF5 = lF5 = LabelFrame(
            fr2,
            style="RoundedFrame",
            padding=(10, 1, 10, 10),
            text='Orientation of \nProgressbar \nScale \nScrollbar')
        lF5.grid(row=0, column=0, padx=5, pady=5, sticky='nw')
        self.orient = StringVar()
        orientT = ['Horizontal', 'Vertical']
        for ix, val in enumerate(orientT):
            rb = Radiobutton(lF5,
                             text=val,
                             value=val,
                             command=self.orient_command,
                             variable=self.orient,
                             state='disabled')
            rb.grid(row=ix, column=0, sticky='w')
            self.rbs.append(rb)

        # create Radio Buttons to choose themes
        themes = {
            "alt": "alt - standard",
            "clam": "clam - standard",
            "classic": "classic - standard",
            "default": "default - standard"
        }

        self.lF1 = LabelFrame(self.fr1,
                              text='Select Theme',
                              style="RoundedFrame",
                              padding=(10, 1, 10, 10))
        self.lF1.grid(row=2, column=0, sticky='n')
        self.theme_value = StringVar()
        for ix, val in enumerate(themes):
            rb1 = Radiobutton(self.lF1,
                              text=themes[val],
                              value=val,
                              state='disabled',
                              variable=self.theme_value,
                              command=self.theme_command)
            rb1.grid(row=ix, column=0, padx=10, sticky='nw')
            self.rbs1.append(rb1)
Esempio n. 3
0
def Choice():
    window = Tk()
    window.geometry('350x400')
    l1 = Label(window, text='View Option Contract for:', bg='#f2f1cc')
    l1.place(x=30, y=35, height=35, width=150)
    b1 = Button(
        window,
        text="NIFTY",
        font=('Arial Bold', 10),
    )
    b1.configure(command=lambda: IsSelected(b1['text']), bg='#e2d1d0')
    b1.place(x=180, y=35, height=35, width=100)
    b2 = Button(window, text="BANKNIFTY", font=('Arial Bold', 10))
    l2 = Label(window, text='View Option Contract for:', bg='#f2f1cc')
    l2.place(x=30, y=110, height=35, width=150)
    b2.configure(command=lambda: IsSelected(b2['text']), bg='#e2d1d0')
    b2.place(x=180, y=110, height=35, width=100)
    l3 = Label(window, text='Select Symbol', font=('Arial', 10), bg='#f2f1cc')
    l3.place(x=60, y=185, height=35, width=100)
    cb = Combobox(window)
    cb['values'] = [
        "AARTIIND",
        "ACC",
        "ADANIENT",
        "ADANIPORTS",
        "AMARAJABAT",
        "AMBUJACEM",
        "APOLLOHOSP",
        "APOLLOTYRE",
        "ASHOKLEY",
        "ASIANPAINT",
        "AUROPHARMA",
        "AXISBANK",
        "BAJAJ-AUTO",
        "BAJAJFINSV",
        "BAJFINANCE",
        "BALKRISIND",
        "BANDHANBNK",
        "BANKBARODA",
        "BATAINDIA",
        "BEL",
        "BERGEPAINT",
        "BHARATFORG",
        "BHARTIARTL",
        "BHEL",
        "BIOCON",
        "BOSCHLTD",
        "BPCL",
        "BRITANNIA",
        "CADILAHC",
        "CANBK",
        "CHOLAFIN",
        "CIPLA",
        "COALINDIA",
        "COFORGE",
        "COLPAL",
        "CONCOR",
        "CUMMINSIND",
        "DABUR",
        "DIVISLAB",
        "DLF",
        "DRREDDY",
        "EICHERMOT",
        "ESCORTS",
        "EXIDEIND",
        "FEDERALBNK",
        "FINNIFTY",
        "GAIL",
        "GLENMARK",
        "GMRINFRA",
        "GODREJCP",
        "GODREJPROP",
        "GRASIM",
        "HAVELLS",
        "HCLTECH",
        "HDFC",
        "HDFCAMC",
        "HDFCBANK",
        "HDFCLIFE",
        "HEROMOTOCO",
        "HINDALCO",
        "HINDPETRO",
        "HINDUNILVR",
        "IBULHSGFIN",
        "ICICIBANK",
        "ICICIGI",
        "ICICIPRULI",
        "IDEA",
        "IDFCFIRSTB",
        "IGL",
        "INDIGO",
        "INDUSINDBK",
        "INDUSTOWER",
        "INFRATEL",
        "INFY",
        "IOC",
        "ITC",
        "JINDALSTEL",
        "JSWSTEEL",
        "JUBLFOOD",
        "KOTAKBANK",
        "L&TFH",
        "LALPATHLAB",
        "LICHSGFIN",
        "LT",
        "LUPIN",
        "M&M",
        "M&MFIN",
        "MANAPPURAM",
        "MARICO",
        "MARUTI",
        "MCDOWELL-N",
        "MFSL",
        "MGL",
        "MINDTREE",
        "MOTHERSUMI",
        "MRF",
        "MUTHOOTFIN",
        "NATIONALUM",
        "NAUKRI",
        "NESTLEIND",
        "NMDC",
        "NTPC",
        "ONGC",
        "PAGEIND",
        "PEL",
        "PETRONET",
        "PFC",
        "PIDILITIND",
        "PNB",
        "POWERGRID",
        "PVR",
        "RAMCOCEM",
        "RBLBANK",
        "RECLTD",
        "RELIANCE",
        "SAIL",
        "SBILIFE",
        "SBIN",
        "SHREECEM",
        "SIEMENS",
        "SRF",
        "SRTRANSFIN",
        "SUNPHARMA",
        "SUNTV",
        "TATACHEM",
        "TATACONSUM",
        "TATAMOTORS",
        "TATAPOWER",
        "TATASTEEL",
        "TCS",
        "TECHM",
        "TITAN",
        "TORNTPHARM",
        "TORNTPOWER",
        "TVSMOTOR",
        "UBL",
        "ULTRACEMCO",
        "UPL",
        "VEDL",
        "ZEEL",
        "VOLTAS",
    ]
    cb.current(0)
    cb.place(x=160, y=185, height=35, width=100)
    l4 = Label(window,
               text="Refresh in (minutes):",
               font=('Arial', 10),
               bg="#f2f1cc")
    l4.place(x=25, y=260, height=40, width=130)
    rad1 = Radiobutton(window,
                       text='5',
                       value=1,
                       command=lambda: refereshPeriod(5))
    rad2 = Radiobutton(window,
                       text='15',
                       value=0,
                       command=lambda: refereshPeriod(15))
    rad3 = Radiobutton(window,
                       text='30',
                       value=3,
                       command=lambda: refereshPeriod(30))
    rad4 = Radiobutton(window,
                       text='60',
                       value=4,
                       command=lambda: refereshPeriod(60))
    rad1.place(x=160, y=260, height=40, width=30)
    rad2.place(x=200, y=260, height=40, width=35)
    rad3.place(x=240, y=260, height=40, width=35)
    rad4.place(x=280, y=260, height=40, width=35)
    l5 = Label(window,
               text="For non-commerical use only.",
               font=('Arial', 10),
               fg='red')
    l5.place(x=75, y=375, height=35, width=175)
    cb.bind("<<ComboboxSelected>>", lambda Combobox=cb: IsSelected(cb.get()))
    b3 = Button(window,
                text="View stocks selected.",
                font=('Arial', 10),
                bg='#e2d1d0',
                command=listbox)
    b3.place(x=100, y=325, height=35, width=150)
    window.title('Stock data updater')
    window.resizable(0, 0)
    window.protocol("WM_DELETE_WINDOW", lambda: closeWindow(window))
    window.mainloop()
Esempio n. 4
0
    def __init__(self, root):
        super().__init__(root)
        
        # url ============================
        self.url = StringVar()
        self.url.set(url_use)
        entry = Entry(self, textvariable=self.url,
                      bg='#666699', fg='#FFFFFF')
        entry.grid(row=0, column=0, columnspan=4, sticky=W+E)
        
        #==================================
        # 粘贴并打开
        self.paste_do = Button(self, text='处理网址', command=self.doit,
                               bg='#cc9933')
        self.paste_do.grid(row=1, column=0)
    
        # 状态
        self.status = Label(self, text='待机', fg='blue')
        self.status.grid(row=1, column=1)
        
        # 检查更新
        update_bt = Button(self, text='检测新版本', command=self.checkver)
        update_bt.grid(row=1, column=2)
        
        # 使用帮助
        help = Button(self, text='使用帮助', command=self.help_bt)
        help.grid(row=1, column=3)
        
        #================================
        
        # 辅助格式
        l4 = Label(self, text='辅助格式:')
        l4.grid(row=2, column=0)
        
        self.assist = IntVar()
        self.assist.set(2)
        
        r1 = Radiobutton(self, text='无辅助',
                         variable=self.assist, value=1)
        r1.grid(row=2, column=1)
        
        r2 = Radiobutton(self, text='页码模式',
                         variable=self.assist, value=2)
        r2.grid(row=2, column=2)
        
        self.r3 = Radiobutton(self, text='楼层模式',
                         variable=self.assist, value=3)
        self.r3.grid(row=2, column=3)
        
        # 末页
        l2 = Label(self, text='下载页数(-1为到末页):')
        l2.grid(row=3, column=0, columnspan=2, sticky=E)
        
        self.till = StringVar()
        self.till.set('-1')
        entry = Entry(self, textvariable=self.till, width=7)
        entry.grid(row=3, column=2)
        
        # 删除文件
        delfile = Button(self, text='删输出文件', command=self.delfile,
                         fg='#990000')
        delfile.grid(row=3, column=3)
        
        #====================================
        # 输出文件
        l3 = Label(self, text='输出文件:')
        l3.grid(row=4, column=0)
        
        self.output = StringVar()
        self.output.set('auto.txt')
        self.e_out = Entry(self, textvariable=self.output, width=10)
        self.e_out.grid(row=4, column=1)

        # 重命名
        self.rename = IntVar()
        self.rename.set(0)
        def callCheckbutton():
            v = self.rename.get()
            if v:
                self.e_out.config(state='disabled')
            else:
                self.e_out.config(state='normal')
            
        cb = Checkbutton(self,
                         variable=self.rename,
                         text='自动重命名',
                         command=callCheckbutton)
        cb.grid(row=4, column=2)
        
        # 覆盖
        self.override = IntVar()
        self.override.set(0)
        cb = Checkbutton(self,
                         variable=self.override,
                         text = '覆盖已有文件')
        cb.grid(row=4, column=3)
        
        #====================================
        
        # self
        self.pack()
        
        # fix radiobutton draw
        self.r3.focus_force()
        self.paste_do.focus_force()
    def _create_descrip_tab(self, nb):
        # frame to hold contents
        frame = Frame(nb, name='descrip')

        # widgets to be displayed on 'Description' tab
        # position and set resize behaviour

        frame.rowconfigure(1, weight=1)
        frame.columnconfigure((0, 1), weight=1, uniform=1)
        lf = LabelFrame(frame, text='Animals')
        lf.pack(pady=2, side='left', fill='y')
        themes = [
            'cat', 'dog', 'horse', 'elephant', 'crocodile', 'bat',
            'grouse\nextra line made longer'
        ]
        self.ttkbut = []
        for t in themes:
            b = Button(lf, text=t)
            b.pack(pady=2)
            self.ttkbut.append(b)

        lF2 = LabelFrame(frame, text="Theme Combobox")
        lF2.pack(anchor='nw')
        themes = list(sorted(self.style.get_themes()))
        themes.insert(0, "Pick a theme")
        self.cb = cb = Combobox(lF2,
                                values=themes,
                                state="readonly",
                                height=10)
        cb.set(themes[0])
        cb.bind('<<ComboboxSelected>>', self.change_style)
        cb.grid(row=0, column=0, sticky='nw', pady=5)

        lF3 = LabelFrame(frame, text="Entry")
        lF3.pack(anchor='ne')
        self.en = Entry(lF3)
        self.en.grid(row=0, column=0, sticky='ew', pady=5, padx=5)

        lf1 = LabelFrame(frame, text='Checkbuttons')
        lf1.pack(pady=2, side='left', fill='y')

        # control variables
        self.enabled = IntVar()
        self.cheese = IntVar()
        self.tomato = IntVar()
        self.basil = IntVar()
        self.oregano = IntVar()
        # checkbuttons
        self.cbOpt = Checkbutton(lf1,
                                 text='Enabled',
                                 variable=self.enabled,
                                 command=self._toggle_opt)
        cbCheese = Checkbutton(text='Cheese',
                               variable=self.cheese,
                               command=self._show_vars)
        cbTomato = Checkbutton(text='Tomato',
                               variable=self.tomato,
                               command=self._show_vars)
        sep1 = Separator(orient='h')
        cbBasil = Checkbutton(text='Basil',
                              variable=self.basil,
                              command=self._show_vars)
        cbOregano = Checkbutton(text='Oregano',
                                variable=self.oregano,
                                command=self._show_vars)
        sep2 = Separator(orient='h')

        self.cbs = [
            self.cbOpt, sep1, cbCheese, cbTomato, sep2, cbBasil, cbOregano
        ]
        for opt in self.cbs:
            if opt.winfo_class() == 'TCheckbutton':
                opt.configure(onvalue=1, offvalue=0)
                opt.setvar(opt.cget('variable'), 0)

            opt.pack(in_=lf1,
                     side='top',
                     fill='x',
                     pady=2,
                     padx=5,
                     anchor='nw')

        lf2 = LabelFrame(frame, text='Radiobuttons', labelanchor='n')
        lf2.pack(pady=2, side='left', fill='y')

        self.rb = []
        self.happiness = StringVar()
        for s in ['Great', 'Good', 'OK', 'Poor', 'Awful']:
            b = Radiobutton(lf2,
                            text=s,
                            value=s,
                            variable=self.happiness,
                            command=lambda s=s: self._show_vars())
            b.pack(anchor='nw', side='top', fill='x', pady=2)
            self.rb.append(b)

        right = LabelFrame(frame, text='Control Variables')
        right.pack(pady=2, side='left', fill='y')

        self.vb0 = Label(right, font=('Courier', 10))
        self.vb1 = Label(right, font=('Courier', 10))
        self.vb2 = Label(right, font=('Courier', 10))
        self.vb3 = Label(right, font=('Courier', 10))
        self.vb4 = Label(right, font=('Courier', 10))
        self.vb5 = Label(right, font=('Courier', 10))

        self.vb0.pack(anchor='nw', pady=3)
        self.vb1.pack(anchor='nw', pady=3)
        self.vb2.pack(anchor='nw', pady=3)
        self.vb3.pack(anchor='nw', pady=3)
        self.vb4.pack(anchor='nw', pady=3)
        self.vb5.pack(anchor='nw', pady=3)

        self._show_vars()
        # add to notebook (underline = index for short-cut character)
        nb.add(frame, text='Description', underline=0, padding=2)
Esempio n. 6
0
    def __init__(self, parent):
        LabelFrame.__init__(self, parent, text="Model", borderwidth=5)

        self.selection = tkinter.IntVar()

        self.exponential = Radiobutton(self,
                                       text="Exponential model",
                                       variable=self.selection,
                                       value=Model.EXP.value,
                                       command=self.changeSelection)
        self.powerlaw = Radiobutton(self,
                                    text="Power law model",
                                    variable=self.selection,
                                    value=Model.POW.value,
                                    command=self.changeSelection)
        self.weibull = Radiobutton(self,
                                   text="Weibull model",
                                   variable=self.selection,
                                   value=Model.WEI.value,
                                   command=self.changeSelection)

        self.exponential.grid(row=0,
                              column=0,
                              sticky="W",
                              padx=10,
                              pady=(self.topPadding, 5))
        self.powerlaw.grid(row=1, column=0, sticky="W", padx=10, pady=5)
        self.weibull.grid(row=2, column=0, sticky="W", padx=10, pady=(5, 0))

        seperator = Separator(self, orient=tkinter.VERTICAL)
        seperator.grid(row=0,
                       column=1,
                       rowspan=3,
                       sticky="NS",
                       padx=(20, 10),
                       pady=(self.topPadding, 0))

        ## Exponential setup

        self.expNumberOfSegments_L = Label(self, text="Number of segments: ")
        self.expNumberOfSegments_E = Entry(self, width=5, justify="right")

        self.expNumberOfSegments_E.insert(
            0, settings.EXP_DEFAULT_NUMBER_OF_SEGMENTS)

        self.expWidgets = [
            self.expNumberOfSegments_L, self.expNumberOfSegments_E
        ]

        ## Power law setup

        self.powProximalLimit_L = Label(self,
                                        text="Proximal limit of integration: ")
        self.powProximalLimit_E = Entry(self, width=5, justify="right")
        self.powDistalLimit_L = Label(self,
                                      text="Distal limit of integration: ")
        self.powDistalLimit_E = Entry(self, width=5, justify="right")

        self.powProximalLimit_E.insert(0, settings.POW_DEFAULT_PROXIMAL_LIMIT)
        self.powDistalLimit_E.insert(0, settings.POW_DEFAULT_DISTAL_LIMIT)

        self.powWidgets = [
            self.powProximalLimit_L, self.powProximalLimit_E,
            self.powDistalLimit_L, self.powDistalLimit_E
        ]

        ## Weibull setup

        self.weiNumberOfRuns_L = Label(self, text="Number of runs: ")
        self.weiNumberOfRuns_E = Entry(self, width=5, justify="right")
        self.weiIterationsPerRun_L = Label(self, text="Iterations per run: ")
        self.weiIterationsPerRun_E = Entry(self, width=5, justify="right")

        self.weiEstimatedTime_L = Label(self, text="Estimated time (s): ")
        self.weiEstimatedTime_E = CustomEntry(self, width=5, justify="right")
        self.weiEstimatedTime_E.setUserEditable(False)

        self.weiLambdaLowerBoundL = Label(self, text="\u03BB lower bound:")
        self.weiLambdaUpperBoundL = Label(self, text="\u03BB upper bound:")
        self.weiLambdaLowerBoundE = Entry(self, width=5, justify="right")
        self.weiLambdaUpperBoundE = Entry(self, width=5, justify="right")

        self.weiKLowerBoundL = Label(self, text="k lower bound:")
        self.weiKUpperBoundL = Label(self, text="k upper bound:")
        self.weiKLowerBoundE = Entry(self, width=5, justify="right")
        self.weiKUpperBoundE = Entry(self, width=5, justify="right")

        self.weiNumberOfRuns_E.insert(0, settings.WEI_DEFAULT_NUMBER_OF_RUNS)
        self.weiIterationsPerRun_E.insert(
            0, settings.WEI_DEFAULT_ITERATIONS_PER_RUN)
        self.weiLambdaLowerBoundE.insert(
            0, settings.WEI_DEFAULT_LAMBDA_LOWER_BOUND)
        self.weiLambdaUpperBoundE.insert(
            0, settings.WEI_DEFAULT_LAMBDA_UPPER_BOUND)
        self.weiKLowerBoundE.insert(0, settings.WEI_DEFAULT_K_LOWER_BOUND)
        self.weiKUpperBoundE.insert(0, settings.WEI_DEFAULT_K_UPPER_BOUND)

        self.weiWidgets = [
            self.weiNumberOfRuns_L, self.weiNumberOfRuns_E,
            self.weiIterationsPerRun_L, self.weiIterationsPerRun_E,
            self.weiEstimatedTime_L, self.weiEstimatedTime_E,
            self.weiLambdaLowerBoundL, self.weiLambdaUpperBoundL,
            self.weiLambdaLowerBoundE, self.weiLambdaUpperBoundE,
            self.weiKLowerBoundL, self.weiKUpperBoundL, self.weiKLowerBoundE,
            self.weiKUpperBoundE
        ]

        ## General

        self.currentWidgets = []
        self.selection.set(Model.EXP.value)
        self.changeSelection()
Esempio n. 7
0
    def __init__(self, master):
        self.master = master

        my_font = Font(family="Times New Roman", size=14)
        option_style = ttk.Style()
        option_style.configure('FRL.TCombobox', font=my_font)

        # button_style = ttk.Style()
        # button_style.configure('FRL.TButton', font=my_font)

        self.master.option_add('*TCombobox*Listbox.font', my_font)
        self.master.option_add('*TCombobox*Arrow', 100)

        self.hours = self._initiate_hours()
        self.minutes = self._initiate_minutes()
        self.stations = self._initiate_stations()

        self.master.title("Digital Audio Recorder")
        self.master.geometry('1000x400')

        self.choose_station_box = Combobox(self.master, font=my_font)
        self.choose_station_box['values'] = list(self.stations.keys())
        self.choose_station_box.current(0)
        self.choose_station_box.grid(row=0, columnspan=10, padx=(20, 20), pady=(20, 20))

        # Start Time

        self.start_time_label = Label(self.master, text='Record Start Time', font=my_font)
        self.start_time_label.grid(row=1, column=0, padx=(20, 20), pady=(20, 20))

        self.start_time_hour_box = Combobox(self.master, font=my_font)
        self.start_time_hour_box['values'] = self.hours
        self.start_time_hour_box.current(0)
        self.start_time_hour_box.grid(row=1, column=1, padx=(20, 20), pady=(20, 20))

        self.start_time_minute_box = Combobox(self.master, font=my_font)
        self.start_time_minute_box['values'] = self.minutes
        self.start_time_minute_box.current(0)
        self.start_time_minute_box.grid(row=1, column=2, padx=(20, 20), pady=(20, 20))

        self.start_time_am_or_pm = StringVar(None, 'AM')

        self.start_time_am = Radiobutton(self.master, text='AM', value='AM', variable=self.start_time_am_or_pm)
        self.start_time_am.grid(row=1, column=3, padx=(20, 20), pady=(20, 20))

        self.start_time_pm = Radiobutton(self.master, text='PM', value='PM', variable=self.start_time_am_or_pm)
        self.start_time_pm.grid(row=1, column=4, padx=(20, 20), pady=(20, 20))

        # End Time

        self.end_time_label = Label(self.master, text='Record End Time', font=my_font)
        self.end_time_label.grid(row=2, column=0, padx=(20, 20), pady=(20, 20))

        self.end_time_hour_box = Combobox(self.master, font=my_font)
        self.end_time_hour_box['values'] = self.hours
        self.end_time_hour_box.current(0)
        self.end_time_hour_box.grid(row=2, column=1, padx=(20, 20), pady=(20, 20))

        self.end_time_minute_box = Combobox(self.master, font=my_font)
        self.end_time_minute_box['values'] = self.minutes
        self.end_time_minute_box.current(0)
        self.end_time_minute_box.grid(row=2, column=2, padx=(20, 20), pady=(20, 20))

        self.end_time_am_or_pm = StringVar(None, 'AM')

        self.end_time_am = Radiobutton(self.master, text='AM', value='AM', variable=self.end_time_am_or_pm)
        self.end_time_am.grid(row=2, column=3, padx=(20, 20), pady=(20, 20))

        self.end_time_pm = Radiobutton(self.master, text='PM', value='PM', variable=self.end_time_am_or_pm)
        self.end_time_pm.grid(row=2, column=4, padx=(20, 20), pady=(20, 20))

        self.record_button = Button(self.master, text="Record", command=self._record_button_clicked, font=my_font)
        self.record_button.grid(row=10, column=10, padx=(20, 20), pady=(20, 20))
Esempio n. 8
0
    def __init__(self):
        Tk.__init__(self)

        # window properties
        self.title(string="Screen Recorder by Darsh Sharma")
        self.iconbitmap("icon.ico")
        self.resizable(width=False, height=False)

        ffmpegAvailable = False
        for item in os.listdir():
            if item == "ffmpeg.exe":
                ffmpegAvailable = True
                break
        if not ffmpegAvailable:
            self.withdraw()
            if messagebox.askyesno(
                    "FFmpeg Not Found",
                    "ffmpeg.exe could not be found in screen recorder's directory. Do you want to be redirected to the ffmpeg download website? to pehele mera channel subscribe karo"
            ):
                webbrowser.open_new_tab(
                    "https://www.youtube.com/channel/UCznpesyijPSg4fK082eDEow/videos"
                )
            exit()
        self.cmdGen = cmdGen(
        )  # create a command generator object to store settings

        # file name
        label1 = Label(self, text="File Name:")
        label1.grid(row=0, column=0, sticky="")
        self.entry1 = Entry(self)
        self.entry1.grid(row=0, column=1, sticky="ew")

        # ensure the existance of the "ScreenCaptures" directory
        try:
            os.mkdir("ScreenCaptures by Darsh Sharma")
        except FileExistsError:
            pass
        os.chdir("ScreenCaptures by Darsh Sharma")

        # find a default file name that is currently available.
        defaultFile = "DarshPro.mp4"
        available = False
        fileNum = 0
        while available == False:
            hasMatch = False
            for item in os.listdir():
                if item == defaultFile:
                    hasMatch = True
                    break
            if not hasMatch:
                available = True
            else:
                fileNum += 1
                defaultFile = "DarshPro" + str(fileNum) + ".mp4"
        os.chdir("..")
        self.entry1.insert(END, defaultFile)

        # radio buttons determine what to record
        self.what = StringVar()
        self.what.set("desktop")
        self.radio2 = Radiobutton(self,
                                  text="record the window with the title of: ",
                                  variable=self.what,
                                  value="title",
                                  command=self.enDis1)
        self.radio1 = Radiobutton(self,
                                  text="record the entire desktop",
                                  variable=self.what,
                                  value="desktop",
                                  command=self.enDis)
        self.radio1.grid(row=1, column=0, sticky="w")
        self.radio2.grid(row=2, column=0, sticky="w")
        self.entry2 = Entry(self, state=DISABLED)
        self.entry2.grid(row=2, column=1, sticky="ew")

        # initialize webcam
        self.webcamdevices = Webcam.listCam()
        self.webcamrecorder = Webcam.capturer("")

        # "record from webcam" checkbox
        self.rcchecked = IntVar()
        self.recordcam = Checkbutton(self,
                                     text="Record from webcam",
                                     command=self.checkboxChanged,
                                     variable=self.rcchecked)
        self.recordcam.grid(row=3, column=0)

        # a drop-down allowing you to select the webcam device from the available directshow capture devices
        self.devicename = StringVar(self)
        if self.webcamdevices:
            self.devicename.set(self.webcamdevices[0])
            self.deviceselector = OptionMenu(self, self.devicename,
                                             *self.webcamdevices)
            self.deviceselector.config(state=DISABLED)
            self.deviceselector.grid(row=3, column=1)
        else:
            self.devicename.set("NO DEVICES AVAILABLE")
            self.recordcam.config(state=DISABLED)
            self.deviceselector = OptionMenu(self, self.devicename,
                                             "NO DEVICES AVAILABLE")
            self.deviceselector.config(state=DISABLED)
            self.deviceselector.grid(row=3, column=1)

        self.opButton = Button(self,
                               text="⚙ Additional Options...",
                               command=self.openSettings)
        self.opButton.grid(row=4, column=1, sticky='e')

        # the "start recording" button
        self.startButton = Button(self,
                                  text="⏺ Start Recording",
                                  command=self.startRecord)
        self.startButton.grid(row=5, column=0, columnspan=2)

        # some variables
        self.recording = False  # are we recording?
        self.proc = None  # the popen object for ffmpeg (during screenrecord)
        self.recorder = recordFile.recorder(
        )  # the "recorder" object for audio (see recordFile.py)
        self.mergeProcess = None  # the popen object for ffmpeg (while merging video and audio files)

        # start the ffmpeg monitoring callback
        self.pollClosed()
Esempio n. 9
0
lbl_current_A = Label(lbl_current, text="Ток, А")
lbl_current_A.place(x=90, y=5)

spinbox_angle = Spinbox(lbl_current, from_=0, to=360, width=5)
spinbox_angle.place(x=170, y=5)
spinbox_angle.delete(0, "end")
spinbox_angle.insert(0, 0)
lbl_angle = Label(lbl_current, text="Угол")
lbl_angle.place(x=260, y=5)

lbl_phase = LabelFrame(window, text="Выберите задействованные фазы")
lbl_phase.place(x=15, y=135, width=350, heigh=60)

sel_phase = IntVar()
sel_phase.set(103)
rad_A = Radiobutton(lbl_phase, text='A', value=113, variable=sel_phase)
rad_A.place(x=5, y=5)
rad_B = Radiobutton(lbl_phase, text='B', value=123, variable=sel_phase)
rad_B.place(x=45, y=5)
rad_C = Radiobutton(lbl_phase, text='C', value=133, variable=sel_phase)
rad_C.place(x=85, y=5)
rad_ABC = Radiobutton(lbl_phase, text='ABC', value=103, variable=sel_phase)
rad_ABC.place(x=125, y=5)

lbl_voltage = LabelFrame(window, text="Установите параметры напряжения")
lbl_voltage.place(x=15, y=200, width=350, heigh=60)

sel_voltage = IntVar()
sel_voltage.set(2)
rad_voltage_57V = Radiobutton(lbl_voltage,
                              text='57В',
Esempio n. 10
0
txt = Entry(window, width=10)
txt.grid(column=1, row=0)

button1 = Button(window, text="Click Me", command=button1_clicked)
button1.grid(column=2, row=0)

combo = Combobox(window)
combo['values'] = ("black", "red", "blue", "purple")
combo.current(1)  # set the selected item
combo.grid(column=0, row=1)

button2 = Button(window, text="Choose", command=button2_clicked)
button2.grid(column=1, row=1)

selected = IntVar()
rad1 = Radiobutton(window, text='First', value=1, variable=selected)
rad2 = Radiobutton(window, text='Second', value=2, variable=selected)
rad3 = Radiobutton(window, text='Third', value=3, variable=selected)
rad1.grid(column=0, row=2)
rad2.grid(column=1, row=2)
rad3.grid(column=2, row=2)
label3 = Label(window, text="")
label3.grid(column=0, row=3)
button3 = Button(window, text="What RadioButton", command=button3_clicked)
button3.grid(column=2, row=3)

canvas1 = Canvas(window, bg="yellow", width=100, height=70)
canvas1.grid(column=3, row=1)
print(canvas1.winfo_width())

window.mainloop()
Esempio n. 11
0
    def show(self):
        self._root.title("RSSIMapper")
        tk.Button(self._root, text="Quit",
                  command=self._root.quit).pack(anchor=tk.NE, padx=10, pady=10)

        tabControl = ttk.Notebook(self._root, padding=5)

        self.tab1 = ttk.Frame(tabControl)
        self.tab2 = ttk.Frame(tabControl)

        tabControl.add(self.tab1, text="Settings", padding=20)
        tabControl.add(self.tab2, text="Map")
        tabControl.pack(expand=1, fill="both")

        def only_numbers(char):
            return char.isdigit()

        validation = self._root.register(only_numbers)

        self.entries = {}
        for field, default_val in self.fields.items():
            row = tk.Frame(self.tab1)
            lab = tk.Label(row, width=22, text=field, anchor="w")
            ent = tk.Entry(row)
            ent.insert(0, default_val)
            row.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5)
            lab.pack(side=tk.LEFT)
            ent.pack(side=tk.LEFT, expand=tk.YES, fill=tk.X)
            self.entries[field] = ent
            if field == "input_csv":
                tk.Button(row,
                          text="Browse",
                          command=lambda: self.browse_files("input_csv")).pack(
                              side=tk.RIGHT, padx=(10, 0))
            elif field == "input_shapefile":
                tk.Button(
                    row,
                    text="Browse",
                    command=lambda: self.browse_files("input_shapefile"),
                ).pack(side=tk.RIGHT, padx=(10, 0))
            elif field in [
                    "baudrate",
                    "serial_timeout",
                    "measurement_timeout",
                    "n_measurements_per_point",
            ]:
                ent.configure(validate="key",
                              validatecommand=(validation, "%S"))

        tk.Button(self.tab1, text="Save",
                  command=self._update_program_data).pack(pady=20)
        self._progress_label = tk.Label(self.tab2)
        self._progress_label.pack(pady=10)

        def show_selected_map():
            self._presenter.update_map(self.chosen_value.get())

        self.chosen_value = tk.IntVar()
        self.chosen_value.set(RSSI_CHOICE)
        Radiobutton(
            self.tab2,
            text="RSSI",
            variable=self.chosen_value,
            value=RSSI_CHOICE,
            command=show_selected_map,
        ).pack()
        Radiobutton(
            self.tab2,
            text="Percent delivered",
            variable=self.chosen_value,
            value=PERCENT_CHOICE,
            command=show_selected_map,
        ).pack()
        tk.Button(self.tab2, text="Clear map",
                  command=self._clear_map).pack(pady=10)
        self._presenter.update_map(self.chosen_value.get())
        self._refresh_received_status()
        self._root.mainloop()
    def _create_widgets(self):
        """GUI building"""
        # File widgets
        self._filename_label = Label(self._master, width="22", anchor="e", text="Access File (*.mdb, *.accdb):")
        self._filename_label.grid(row=0, column=0)

        self._filename_path_label = Label(self._master, width="50", anchor="w", textvariable=self._file_path, bg="#cccccc")
        self._filename_path_label.grid(row=0, column=1)

        self._browse_file_button = Button(self._master, text="...", width="3", command=self._browse_file)
        self._browse_file_button.grid(row=0, column=2)

        # Password widget
        self._password_label = Label(self._master, width="22", anchor="e", text="Password (else leave empty):")
        self._password_label.grid(row=1, column=0)

        self._password_entry = Entry(self._master, width="58", show="*")
        self._password_entry.grid(row=1, column=1)

        self._password_show_image = PhotoImage(file=path.join(module_dir, "images\\watch_pwd.png")).subsample(8, 8)
        self._password_show_button = Button(self._master, width="3", command=self._show_hide_password, image=self._password_show_image)
        self._password_show_button.grid(row=1, column=2)

        # Checkbox widget
        self._same_dir_as_file_checkbox = Checkbutton(self._master, width="50", text="Same directory as source file", var=self._same_dir, command=self._same_dir_as_file)
        self._same_dir_as_file_checkbox.grid(row=2, column=1, pady=8)

        # Output widgets
        self._output_label = Label(self._master, width="22", anchor="e", text="Output directory:")
        self._output_label.grid(row=3, column=0)

        self._output_dir_label = Label(self._master, width="50", anchor="w", textvariable=self._file_path,
                                       bg="#cccccc")
        self._output_dir_label.grid(row=3, column=1)

        self._browse_dir_button = Button(self._master, text="...", width="3", command=self._browse_dir)
        self._browse_dir_button.grid(row=3, column=2)

        # Radio buttons for PostgreSQL or MySQL/MariaDB
        self._db_type_label = Label(self._master, width="22", anchor="e", text="Database type:")
        self._db_type_label.grid(row=4, column=0)

        self._db_type_frame = Frame(self._master)
        self._db_type_frame.grid(row=4, column=1, columnspan=2, pady=5)

        self._radio_button_postgres = Radiobutton(self._db_type_frame, text="PostgreSQL", var=self._db_type, value=self.DB_TYPE_POSTGRESQL(), width="13")
        self._radio_button_postgres.grid(row=0, column=0)

        self._radio_button_mariadb = Radiobutton(self._db_type_frame, text="MariaDB", var=self._db_type, value=self.DB_TYPE_MARIADB(), width="13")
        self._radio_button_mariadb.grid(row=0, column=1)

        self._radio_button_mysql = Radiobutton(self._db_type_frame, text="MySQL", var=self._db_type, value=self.DB_TYPE_MYSQL(), width="13")
        self._radio_button_mysql.grid(row=0, column=2)

        # Convert widget & progressbar
        self._convert_frame = Frame(self._master)
        self._convert_frame.grid(row=5, column=0, columnspan=2, pady=5)

        self._convert_button = Button(self._convert_frame, width="84", text="CREATE SQL FILE", command=self.convertSQL, state="disabled")
        self._convert_button.grid(row=0, column=0)

        self._convert_progressbar = Progressbar(self._convert_frame, length="512")
        self._convert_progressbar.grid(row=1, column=0)
Esempio n. 13
0

fr = Frame(root)
fr.grid(column=0, row=0, sticky='nsew')

states = [
    'active', 'alternate', 'background', 'disabled', 'focus', 'invalid',
    'pressed', 'readonly', 'selected'
]
# Create rasio buttons which will display widget states

state_val = StringVar()
for iy, state in enumerate(states):
    st_rb = Radiobutton(fr,
                        value=state,
                        text=state,
                        variable=state_val,
                        command=change_state)
    st_rb.grid(column=0, row=iy, padx=5, pady=5, sticky='nw')

img1 = PhotoImage("combo-n", file='../images/piratz/combo-n.png')
img2 = PhotoImage("combo-ra", file='../images/piratz/combo-ra.png')
img3 = PhotoImage("combo-rd", file='../images/piratz/combo-rd.png')
img4 = PhotoImage("combo-rf", file='../images/piratz/combo-rf.png')
img5 = PhotoImage("combo-rn", file='../images/piratz/combo-rn.png')
img6 = PhotoImage("combo-rp", file='../images/piratz/combo-rp.png')
img7 = PhotoImage("comboarrow-a", file='../images/piratz/comboarrow-a.png')
img8 = PhotoImage("comboarrow-d", file='../images/piratz/comboarrow-d.png')
img9 = PhotoImage("comboarrow-n", file='../images/piratz/comboarrow-n.png')
img10 = PhotoImage("comboarrow-p", file='../images/piratz/comboarrow-p.png')
Esempio n. 14
0
    def launch(self):
        self.grid()
        self.master.title(self.title)
        self.master.geometry("950x950+500+100")

        # Use this list to keep references to the images used in the buttons. Without a reference
        # the garbage collector will remove them!
        self.images = []

        # Create option frame where the buttons are located and the view frame where the images
        # are shown
        self.master.rowconfigure(1, weight=1)
        self.master.columnconfigure(0, weight=1)
        self.master.bind('<Configure>', self.kernel.layout)
        self.master.protocol("WM_DELETE_WINDOW", self.kernel.close_filter)
        self.option_frame = Frame(self.master, bg="white")
        self.option_frame.grid(row=0, column=0, sticky=W + E + N + S)
        self.view_canvas = ttk.Canvas(self.master,
                                      borderwidth=0,
                                      background="white")

        self.view_frame = Frame(self.view_canvas, background="white")
        self.vsb = Scrollbar(self.master,
                             orient="vertical",
                             command=self.view_canvas.yview)
        self.view_canvas.configure(yscrollcommand=self.vsb.set)

        self.vsb.grid(row=1, column=0, sticky=E + N + S)
        self.view_canvas.grid(row=1, column=0, sticky=W + E + N + S)
        self.view_canvas.create_window((4, 4),
                                       window=self.view_frame,
                                       anchor="nw",
                                       tags="self.frame")

        self.view_frame.bind("<Configure>", self.onFrameConfigure)

        # This list is used to keep a reference of the images displayed in the view frame.
        self.photos = []

        # This list is to be able to reference the labels and delete them when the filter
        # is updated.
        self.view_labels = []
        self.view_checks = []
        self.view_ch_val = []

        btn_frame = Frame(self.option_frame, bg="white")
        btn_frame.grid(row=0,
                       column=2,
                       rowspan=1,
                       padx=(30, 30),
                       sticky=W + E + N + S)

        btn = Button(btn_frame, text="Pick", command=self.kernel.send_pick)
        btn.grid(row=0, column=0, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame, text="Point", command=self.kernel.send_point)
        btn.grid(row=1, column=0, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Show labels",
                     command=self.kernel.send_showLabels)
        btn.grid(row=2, column=0, padx=(5, 5), sticky=N + W + E)
        self.start_btn = Button(btn_frame,
                                text="Start",
                                command=self.kernel.start)
        self.start_btn.grid(row=0, column=1, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="End session",
                     command=self.kernel.close_filter)
        btn.grid(row=1, column=1, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Unselect all",
                     command=self.kernel.unselect)
        btn.grid(row=2, column=1, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Remove",
                     command=self.kernel.find_and_remove)
        btn.grid(row=3, column=1, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Hide labels",
                     command=self.kernel.send_hideLabels)
        btn.grid(row=3, column=0, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame, text="Clear", command=self.kernel.send_clear)
        btn.grid(row=0, column=3, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Planning failed",
                     command=self.kernel.send_sorryPlanning)
        btn.grid(row=1, column=3, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Grasping failed",
                     command=self.kernel.send_sorryGrasping)
        btn.grid(row=2, column=3, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="Not understand",
                     command=self.kernel.send_badRequest)
        btn.grid(row=3, column=3, padx=(5, 5), sticky=N + W + E)
        btn = Button(btn_frame,
                     text="New request",
                     command=self.kernel.send_newRequest)
        btn.grid(row=2, column=2, padx=(5, 5), sticky=N + W + E)

        self.send = IntVar()
        self.send.set(1)
        Checkbutton(btn_frame,
                    text="Send data to server",
                    variable=self.send,
                    bg="white").grid(row=3, column=2, sticky=N + W + E)

        img1 = ImageTk.PhotoImage(
            PIL.Image.open(
                resource_filename("Commands.resources.images", "back.png")))
        self.init_lbl = Label(btn_frame, image=img1, bg="white")
        self.init_lbl.grid(row=0, column=2, padx=(5, 5), sticky=N + W + E)
        self.images.append(img1)

        # Set up the option frame. Start with the color radiobuttons
        self.color_frame = Frame(self.option_frame, background="white")
        self.color_frame.grid(row=0,
                              column=0,
                              rowspan=2,
                              padx=(30, 30),
                              sticky=W + E + N + S)
        lbl = Label(self.color_frame, text="Color filter", background="white")
        lbl.grid(row=0, column=0, columnspan=5)

        self.color = StringVar()
        self.color.set("all")
        colors = self.kernel.get_colors()
        image = PIL.Image.open(
            resource_filename("Commands.resources.images",
                              "default_dont_know.png"))
        photo_def = ImageTk.PhotoImage(image)
        image_select = PIL.Image.open(
            resource_filename("Commands.resources.images",
                              "default_dont_know_sel.png"))
        photo_select_def = ImageTk.PhotoImage(image_select)
        rb1 = Radiobutton(self.color_frame,
                          image=photo_def,
                          selectimage=photo_select_def,
                          variable=self.color,
                          value="all",
                          command=lambda: self.kernel.update_filter(self),
                          indicatoron=False)
        rb1.grid(row=1, column=0, rowspan=2, sticky=W + E + N + S)

        self.images.append(photo_select_def)
        self.images.append(photo_def)
        for i, col in enumerate(colors):
            image = PIL.Image.open(
                resource_filename("Commands.resources.images",
                                  "{}.png".format(col)))
            photo = ImageTk.PhotoImage(image)
            image_select = PIL.Image.open(
                resource_filename("Commands.resources.images",
                                  "{}_sel.png".format(col)))
            photo_select = ImageTk.PhotoImage(image_select)
            rb = Radiobutton(self.color_frame,
                             image=photo,
                             selectimage=photo_select,
                             variable=self.color,
                             value=col,
                             command=lambda: self.kernel.update_filter(self),
                             indicatoron=False)
            rb.grid(row=(int((i + 1) / 5) * 2) + 1,
                    column=(i + 1) % 5,
                    rowspan=2,
                    sticky=W + E + N + S)
            rb.deselect()
            self.images.append(photo_select)
            self.images.append(photo)

        self.shape_frame = Frame(self.option_frame, background="white")
        self.shape_frame.grid(row=0,
                              column=1,
                              rowspan=2,
                              padx=(30, 30),
                              sticky=W + E + N + S)
        lbl = Label(self.shape_frame, text="Shape filter", background="white")
        lbl.grid(row=0, column=0, columnspan=5)

        self.shape = StringVar()
        self.shape.set("all")
        shapes = self.kernel.get_shapes()
        rb1 = Radiobutton(self.shape_frame,
                          image=photo_def,
                          selectimage=photo_select_def,
                          variable=self.shape,
                          value="all",
                          command=lambda: self.kernel.update_filter(self),
                          indicatoron=False)
        rb1.grid(row=1, column=0, rowspan=2, sticky=W + E + N + S)

        for i, sha in enumerate(shapes):
            image = PIL.Image.open(
                resource_filename("Commands.resources.images",
                                  "shape_{}.png".format(sha)))
            photo = ImageTk.PhotoImage(image)
            image_select = PIL.Image.open(
                resource_filename("Commands.resources.images",
                                  "shape_{}_sel.png".format(sha)))
            photo_select = ImageTk.PhotoImage(image_select)
            rb = Radiobutton(self.shape_frame,
                             image=photo,
                             selectimage=photo_select,
                             variable=self.shape,
                             value=sha,
                             command=lambda: self.kernel.update_filter(self),
                             indicatoron=False)
            rb.grid(row=(int((i + 1) / 5) * 2) + 1,
                    column=(i + 1) % 5,
                    rowspan=2,
                    sticky=W + E + N + S)
            rb.deselect()
            self.images.append(photo_select)
            self.images.append(photo)

        self.kernel.update_filter(self)
Esempio n. 15
0
combo['values'] = (1, 2, True, 'Текст', '2+2')
combo.current(1)  # вариант по умолчанию
combo.grid(column=0, row=1)

# checkbutton
from tkinter.ttk import Checkbutton

chk_state = BooleanVar()
chk_state.set(True)  # задайте проверку состояния чекбокса
chk = Checkbutton(window, text='Выбрать', var=chk_state)
chk.grid(column=0, row=2)

#radiobutton
from tkinter.ttk import Radiobutton

rad1 = Radiobutton(window, text='Первый', value=1)
rad2 = Radiobutton(window, text='Второй', value=2)
rad3 = Radiobutton(window, text='Третий', value=3)
rad1.grid(column=0, row=3)
rad2.grid(column=1, row=3)
rad3.grid(column=2, row=3)

# alert
from tkinter import messagebox


def clicked2():
    messagebox.showinfo('Заголовок', 'Текст')
    messagebox.askokcancel('Заголовок', 'Текст')