当前位置: 首页>>代码示例>>Python>>正文


Python Frame.configure方法代码示例

本文整理汇总了Python中tkinter.Frame.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.configure方法的具体用法?Python Frame.configure怎么用?Python Frame.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Frame的用法示例。


在下文中一共展示了Frame.configure方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: additems

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
def additems(i, doreturn=False, bgcolor="#555"):
	returnable = []
	for item in i:
		global totalitems
		totalitems += 1
		ff = Frame(f, bg=bgcolor)
		item.body = item.author.name + ' || ' + item.fullname + '\n' + item.body
		item.body = str(totalitems) + '\n' + item.body
		ibody = item.body.replace('\n\n', '\n')
		ifinal = ''
		for paragraph in ibody.split('\n'):
			ifinal += '\n'.join(textwrap.wrap(paragraph))
			ifinal += '\n'  
	
		item.body = ifinal
		ww = 680
		wh = 10 
		wx = 20
		wy = 20 
		#print(ww, wh, wx, wy)
		ff.ww = ww
		ff.wh = wh
		ff.wx = wx
		ff.wy = wy
		ff.body = item.body
		ff.sourceitem = item
		ff.configure(width=ww, height=wh)
		ff.place(x=wx, y=wy)
		ff.bind("<B1-Motion>", framedrag)
		ff.bind("<ButtonRelease-1>", resetdrag)
		ff.pack_propagate(0)
		l = Label(ff, text=item.body, bg="#777")
		l.place(x=10,y=10)
		rt = Text(ff, width= 15, height= (len(ifinal.split('\n'))) - 2)
		rt.sourceitem = item
		rt.place(x=400,y=10)
		rb = Button(ff, text="Reply", command= lambda rep=rt: reply(rep))
		rb.place(x=400,y=wh-20)
		ff.rt = rt
		ff.rb = rb
		if not doreturn:
			widgets.append(ff)
		else:
			returnable.append(ff)
	if doreturn:
		return returnable
	else:
		refreshscreen()
开发者ID:Ninjashibe,项目名称:reddit,代码行数:50,代码来源:tkdrag.py

示例2: configure

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
    def configure(self, cnf={}, **kw):
        """
        Configure this widget.  Use ``label_*`` to configure all
        labels; and ``listbox_*`` to configure all listboxes.  E.g.:

                >>> mlb = MultiListbox(master, 5)
                >>> mlb.configure(label_foreground='red')
                >>> mlb.configure(listbox_foreground='red')
        """
        cnf = dict(list(cnf.items()) + list(kw.items()))
        for (key, val) in list(cnf.items()):
            if key.startswith('label_') or key.startswith('label-'):
                for label in self._labels:
                    label.configure({key[6:]: val})
            elif key.startswith('listbox_') or key.startswith('listbox-'):
                for listbox in self._listboxes:
                    listbox.configure({key[8:]: val})
            else:
                Frame.configure(self, {key:val})
开发者ID:Journo-App,项目名称:flask-by-example,代码行数:21,代码来源:table.py

示例3: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
class SaveGui:

    __name = None

    def __init__(self, main_controller, window):
        self.__main_controller = main_controller
        self.__window = window
        self.__menu = None

    def show(self):
        self.__menu = Frame(self.__window)
        self.__menu.configure(padx=10, pady=20)
        self.__menu.pack(fill=BOTH, expand=True)
        line1 = Frame(self.__menu)
        line1.pack(fill=X)
        self.__name = StringVar()
        self.__name.set("my_game_at_"+strftime("%H:%M")+"-"+strftime("%d.%m.%Y"))
        name_input = Entry(line1)
        name_input.configure(textvariable=self.__name)
        name_input.pack(fill=X)
        line2 = Frame(self.__menu)
        line2.pack(fill=X, pady=20)
        save_btn = Button(line2)
        save_btn.configure(text="Save Game", command=self.save)
        save_btn.pack(fill=X)

    def remove(self):
        if self.__menu is not None:
            self.__menu.destroy()
            self.__memu = None

    def save(self):
        if self.__name is not None:
            self.__main_controller.save_game(self.__name.get())
        self.remove()
        self.__main_controller.show_game()
        self.__main_controller.toggle_game()
        self.__main_controller.toggle_game()
开发者ID:NasskalteJuni,项目名称:GameOfLife,代码行数:40,代码来源:SaveGui.py

示例4: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
class Momentary:
    def __init__(self, master, valves):
        self.valves = valves

        self.master = master
        self.frame1 = Frame(master)
        self.frame2 = Frame(master)

        self.master.configure(bg='sky blue')
        self.frame1.configure(bg='sky blue')
        self.frame2.configure(bg='sky blue')

        index = 0
        while index < 6:
            self.frame1.grid_columnconfigure(index, minsize=6)
            self.frame2.grid_columnconfigure(index, minsize=6)

            self.frame1.grid_rowconfigure(index, minsize=140)
            self.frame2.grid_rowconfigure(index, minsize=140)
            index += 1

        self.end_all_image = PhotoImage(file="img/stop.png").subsample(x=6, y=6)
        self.end_all_button = Button(self.master, image=self.end_all_image, command=lambda: self.end_all() )
        self.end_all_button.config(bg='brown3', activebackground='brown4', border=5, width=850)

        self.label = [Label(self.frame1, textvariable=self.valves[0].get_name()),
                      Label(self.frame1, textvariable=self.valves[1].get_name()),
                      Label(self.frame1, textvariable=self.valves[2].get_name()),
                      Label(self.frame1, textvariable=self.valves[3].get_name()),
                      Label(self.frame2, textvariable=self.valves[4].get_name()),
                      Label(self.frame2, textvariable=self.valves[5].get_name()),
                      Label(self.frame2, textvariable=self.valves[6].get_name()),
                      Label(self.frame2, textvariable=self.valves[7].get_name())]

        row = 0
        for each in self.label:
            each.config(width=7, height=2)
            each.config(bg='sky blue', fg='RoyalBlue4', font=('Lucida Console', 30), padx=18)
            each.grid(row=row % 4, column=0)
            row += 1

        self.lightsA = [LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False)
                        ]

        self.lightsB = [LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False)
                        ]

        self.v = [IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar()]

        for each in self.v:
            each.set(3)

        self.a = [Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(0), value=1),
                  Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(1), value=1),
                  Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(2), value=1),
                  Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(3), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(4), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(5), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(6), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(7), value=1)]

        index = 0
        for each in self.a:
            each.grid(row=index % 4, column=2)
            each.config(width=4, height=2,  indicatoron=0, variable=self.v[index], font=('Lucida Console', 30))
            each.config(bg='SkyBlue4', activebackground='midnight blue', selectcolor='midnight blue', fg='white')
            each.config(activeforeground='white')
            index += 1

        self.b = [Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(0), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(1), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(2), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(3), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(4), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(5), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(6), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(7), value=0)]

        index = 0
#.........这里部分代码省略.........
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:103,代码来源:MomentaryPi2.py

示例5: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]

#.........这里部分代码省略.........
        # log('Get Level reading')
        response = self.level.getReading() or "No response"
        self.setLevelStatus(response)
        return response

    def getNivel(self):
        # log('Get Nivel reading')
        response = '-'.join(map(str,self.nivel.getReading())) if any(self.nivel.getReading()) else "No response"
        self.setNivelStatus(response)
        return response

    def getThermo(self):
        # log('Get Thermo reading')
        response = self.thermo.getReading() or "No response"
        self.setThermoStatus(response)
        return response

    #    #set stop button
    #    def setStop(self):
    #        pass
    #
    #    #set start
    #    def setStart(self):
    #        pass

    # toggle start stop
    def startStop(self):
        # ask comparator if moving, then set "not response"
        self.active = not self.active
        # self.setStatus({0: 'ready', 1: 'active'}[self.active])
        self.setStatus(self.comparatorStatus)

        self.label10.set({0: 'START', 1: 'STOP'}[self.active])
        self.buttonStartStop.configure(bg=startstopbg[self.active],
                                       fg=startstopfg[self.active])
        print(self.active)

        self.observer = self.entryObserver.get().strip()

        if not self.active:
            log('CMP stopped %s' % self.observer)
        else:
            log('CMP started %s' % self.observer)

        if self.active:
            pass  # action after comparator is stopped
        else:
            pass  # action after comparator is started

    # CURRENT_POSITION, NEXT_POSITION, TARGET_POSITION, ITERATION
    def writePauseParams(self,**params):
        with open('.pause') as f:
            f.write('\n'.join([k+' '+' '.join(vals) for k, vals in params.items()]))
        return True

    def readPauseParams(self):
        params = {}
        with open('.pause','r') as f:
            for line in f.readlines():
                key = line.split()[0]
                vals = line.split()[1:]
                params[key] = vals
        os.remove('.pause')
        return params

    def pauseSession(self):
开发者ID:mimmon,项目名称:comparator,代码行数:70,代码来源:compargui.py

示例6: Keypad

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
class Keypad(Frame):
    def __init__(self, master, gui, password):
        Frame.__init__(self, master, bg='sky blue', width=450, height=550)
        self.master.geometry('400x550')
        self.master = master
        self.master.configure(bg='sky blue')
        self.gui = gui
        self.password = password
        self.frame = Frame(master)
        self.frame.pack()
        self.frame.configure(bg='sky blue')

        index = 0
        while index < 5:
            self.frame.grid_rowconfigure(index, minsize=50)
            index += 1

        index = 0
        while index < 5:
            self.frame.grid_columnconfigure(index, minsize=50)
            index += 1

        self.box = Entry(self.frame)

        self.box.grid(row=0, columnspan=3)
        self.box.config(font=('Lucida Console', 78), width=6)

        self.list1 = [Button(self.frame, font=('Lucida Console', 30), text='1', command=lambda: self.bob_print(1)),
                 Button(self.frame, font=('Lucida Console', 30), text='2', command=lambda: self.bob_print(2)),
                 Button(self.frame, font=('Lucida Console', 30), text='3', command=lambda: self.bob_print(3))
                ]

        index = 0
        for each in self.list1:
            each.grid(row=1, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

        self.list2 = [Button(self.frame, font=('Lucida Console', 30), text='4', command=lambda: self.bob_print(4)),
                 Button(self.frame, font=('Lucida Console', 30), text='5', command=lambda: self.bob_print(5)),
                 Button(self.frame, font=('Lucida Console', 30), text='6', command=lambda: self.bob_print(6))
                ]

        index = 0
        for each in self.list2:
            each.grid(row=2, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

        self.list3 = [Button(self.frame, font=('Lucida Console', 30), text='7', command=lambda: self.bob_print(7)),
                 Button(self.frame, font=('Lucida Console', 30), text='8', command=lambda: self.bob_print(8)),
                 Button(self.frame, font=('Lucida Console', 30), text='9', command=lambda: self.bob_print(9))
                ]

        index = 0
        for each in self.list3:
            each.grid(row=3, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

        self.list4 = [Button(self.frame, font=('Lucida Console', 30), text='<', command=lambda: self.bob_print('<')),
                 Button(self.frame, font=('Lucida Console', 30), text='0', command=lambda: self.bob_print(0)),
                 Button(self.frame, font=('Lucida Console', 30), text='E', command=lambda: self.bob_print('E'))
                ]

        index = 0
        for each in self.list4:
            each.grid(row=4, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

    def bob_print(self, character):
        if not (character is '<' or character is 'E'):
            self.box.insert("end", character)
        elif character is '<':
            string = self.box.get()
            self.box.delete(0, 'end')
            self.box.insert('end', string[:-1])
        else:
            if self.box.get() == self.password:
                self.gui.access_granted()
                self.master.destroy()
            else:
                self.box.delete(0, 'end')
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:90,代码来源:Keypad.py

示例7: Frame

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
		inwidget.delete(0.0, "end")




t = tkinter.Tk()

sw = t.winfo_screenwidth()
sh = t.winfo_screenheight()
fw = 720
fh = 406
sw = (sw - fw) / 2
sh = (sh - fh) / 3
t.geometry('%dx%d+%d+%d' % (fw, fh, sw, sh))
f = Frame(t)
f.configure(bg="#008888")
f.pack(fill="both", expand=1)

print('Reddit')
r=bot.rG()
print('Inbox')
inbox = list(r.get_inbox())
done = False
while not done:
	done = True
	for x in inbox:
		if x.new:
			done = False
			inbox.remove(x)
additems(inbox)
开发者ID:Ninjashibe,项目名称:reddit,代码行数:32,代码来源:tkdrag.py

示例8: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]
class testGUI:
    def __init__(self, master):
        """initialize GUI"""
        self.root = master
        self.on = True
        self.connection = None
        Tk().withdraw()
        self.basicframe = Frame(self.root)
        self.basicframe.grid()
        self.basicframe.configure(bg=bgcolor)

        self.fr = Frame(self.basicframe)
        self.fr.grid(row=0, column=0, sticky='new')  # , sticky='W')
        self.fr.configure(bg=bgcolor)
        Grid.columnconfigure(self.root, 0, weight=1)

        self.port = None
        self.baud = None
        # self.inputTypes = ['ascii', 'bin', 'hex', 'mix']
        self.inputType = StringVar()
        self.inputType.set('ascii')
        self.input = 'ascii'

        self.labelPort = Label(self.fr, width=10, text='PORT', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.entryPort = Entry(self.fr, width=20, bd=3, justify='left', bg=inputbox, fg=fgcolor)

        self.labelBaud = Label(self.fr, text='BAUD', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.entryBaud = Entry(self.fr, width=20, bd=3, justify='right', bg=inputbox, fg=fgcolor)

        self.labelType = Label(self.fr, text='TYPE', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.radioType1 = Radiobutton(self.fr, text='ascii', variable=self.inputType, value='ascii', indicatoron=0)
        self.radioType2 = Radiobutton(self.fr, text='bin', variable=self.inputType, value='bin', width=20, indicatoron=0)
        self.radioType3 = Radiobutton(self.fr, text='hex', variable=self.inputType, value='hex', indicatoron=0)
        self.radioType4 = Radiobutton(self.fr, text='mix', variable=self.inputType, value='mix', width=20, indicatoron=0)

        self.labelInput = Label(self.fr, text='INPUT', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.entryInput = Entry(self.fr, width=20, bd=3, justify='left', bg=inputbox, fg=fgcolor)

        self.buttonSend = Button(self.fr, text='SEND', justify='center', bg=buttoncolor, command=self.send)
        self.buttonRead = Button(self.fr, text='READ', justify='center', bg=buttoncolor, command=self.read)
        self.buttonExit = Button(self.fr, text='EXIT', justify='center', bg='red', fg='white', command=self.exit)

        self.response = StringVar()
        self.response.set('')
        self.responseBar = Label(self.fr, textvariable=self.response, justify='left', anchor='w',
                                 bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.status = StringVar()
        self.statusBar = Label(self.fr, textvariable=self.status, justify='left', anchor='nw',
                               bg=bgcolor, fg=fgcolor, font=("Calibri", 10))
        self.status.set('Initialized')


    def emptyRow(self, nrow):
        Label(self.fr, text="", bg=bgcolor).grid(row=nrow, column=0)

    def configure_connection(self):
        self.status.set('Configuring connection')
        print ('Configuring connection')
        self.port = self.entryPort.get()
        self.baud = self.entryBaud.get()
        print ('{}:{}'.format(self.port, self.baud))
        try:
            self.baud = int(self.baud)
        except:
            print ('Something went wrong, setting baud to 0')
            self.entryBaud.delete(0, END)
            self.entryBaud.insert(0, '0')
            self.baud = 0

        self.connection = RS232(comport=self.port, baud=self.baud, dictionary={}, timeout=1)
        self.connection.connect()
        print ('Connection status: {}'.format(self.connection))

        if self.connection and self.connection.conn:
            print ('Connection established, locking current settings')
            self.entryPort.configure(state='disabled')
            self.entryBaud.configure(state='disabled')
        else:
            print ('No connection')
            self.status.set('<No connection>')

    def convertInput(self):
        self.status.set('Converting input')
        typ = self.inputType.get()
        self.input = self.entryInput.get()
        if typ == 'bin':
            newInput = ''.join(lambda x: x in '01', self.input)
            self.input = chr(int(newInput, 2))
        elif typ == 'hex':
            newInput = ''.join(lambda x: x in '0123456789ABCDEF', self.input)
            self.input = chr(int(newInput, 16))
        elif typ == 'mix':
            newInput = self.input
            for i in re.findall('<(\d+?)>', inp):
                newInput = newInput.replace('<{}>'.format(i), chr(int(i)))
            self.input = newInput
        print ('Converted input: {}'.format(self.input))

    def send(self):
        # self.input = self.entryInput.get()
#.........这里部分代码省略.........
开发者ID:mimmon,项目名称:comparator,代码行数:103,代码来源:test232.py

示例9: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import configure [as 别名]

#.........这里部分代码省略.........
        self.lvlStatus.set(text)

    def setIfmStatus(self, text):
        self.ifmStatus.set(text)

    def getIfm(self):
        ifm = IFM()
        response = ifm.read()
        if not response: response = "No response"
        self.setIfmStatus(response)
        return response

    def getLevel(self):
        lvl = LVL()  # možno naèíta� pri __init__
        response = lvl.read()
        if not response: response = "No response"
        self.setLvlStatus(response)
        return response

    #    #set stop button
    #    def setStop(self):
    #        pass
    #
    #    #set start
    #    def setStart(self):
    #        pass

    # toggle start stop
    def startStop(self):
        self.active = not self.active
        self.label10.set({0: 'START', 1: 'STOP'}[self.active])
        self.setStatus({0: 'ready', 1: 'active'}[self.active])

        self.butStartStop.configure(bg=startstopbg[self.active],
                                    fg=startstopfg[self.active])

        self.observer = self.entryObserver.get().strip()

        if not self.active:
            log('CMP stopped %s' % self.observer)
        else:
            log('CMP started %s' % self.observer)

        if self.active:
            pass  # action after comparator is stopped
        else:
            pass  # action after comparator is started

    def getEntries(self):
        return self.stepEntry, self.beginEntry, self.endEntry

    def close(self):
        self.on = False
        if self.active:
            self.startStop()
        self.root.destroy()
        self.root.quit()

    def gotoLow(self):
        low = None
        self.setStatus('Going to LOW')
        try:
            low = float(self.lowEntry.get().strip())
        except:
            pass
        pass  # move carriage to set low
开发者ID:mimmon,项目名称:comparator,代码行数:70,代码来源:komparator.py


注:本文中的tkinter.Frame.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。