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


Python Tk.register方法代码示例

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


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

示例1: imsi_mon_demo

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import register [as 别名]
class imsi_mon_demo(object):

    
    def __init__(self):
        self.imsi_mon_str = '/opt/nokiasiemens/bin/dmxsendcli --unit auto -h *,0102,054f,0,00,04,00,2b24 -b'
        self.imsi_list = imsi_list()
        self.imsi_mon_start = imsi_mon_start(self.imsi_list)
        
        self.imsi_val_1_row = 0
        self.imsi_val_2_row = self.imsi_val_1_row + 1
        self.imsi_val_3_row = self.imsi_val_2_row + 1
        self.imsi_val_4_row = self.imsi_val_3_row + 1
        self.imsi_val_5_row = self.imsi_val_4_row + 1
        self.imsi_val_6_row = self.imsi_val_5_row + 1
        self.imsi_val_7_row = self.imsi_val_6_row + 1
        self.imsi_val_8_row = self.imsi_val_7_row + 1
        self.imsi_val_9_row = self.imsi_val_8_row + 1
        self.imsi_val_10_row = self.imsi_val_9_row + 1
        self.imsi_val_11_row = self.imsi_val_10_row + 1
        self.imsi_val_12_row = self.imsi_val_11_row + 1
        self.imsi_val_13_row = self.imsi_val_12_row + 1
        self.imsi_val_14_row = self.imsi_val_13_row + 1
        self.imsi_val_15_row = self.imsi_val_14_row + 1
        self.imsi_val_16_row = self.imsi_val_15_row + 1
        self.dmx_output_row = self.imsi_val_15_row + 3
        
        self.root = Tk()
        self.root.wm_title("IMSI List notify")
        
        # valid percent substitutions (from the Tk entry man page)
        # %d = Type of action (1=insert, 0=delete, -1 for others)
        # %i = index of char string to be inserted/deleted, or -1
        # %P = value of the entry if the edit is allowed
        # %s = value of entry prior to editing
        # %S = the text string being inserted or deleted, if any
        # %v = the type of validation that is currently set
        # %V = the type of validation that triggered the callback
        #      (key, focusin, focusout, forced)
        # %W = the tk name of the widget
        vcmd = (self.root.register(self.OnValidate), 
                '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')

        self.label_imsi_val_1 = Label (self.root, text= "imsi_val[0]")
        self.label_imsi_val_1.grid(row=self.imsi_val_1_row)
        self.imsi_val_1_text = StringVar()
#         self.imsi_val_1_text.set('ffff')
        Entry(self.root, textvariable=self.imsi_val_1_text, validate="key", validatecommand=vcmd).grid(row=0, column=1)

        self.label_imsi_val_2 = Label (self.root, text= "imsi_val[1]")
        self.label_imsi_val_2.grid(row=self.imsi_val_2_row)
        self.imsi_val_2_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_2_text, validate="key", validatecommand=vcmd).grid(row=1, column=1)
        
        self.label_imsi_val_3 = Label (self.root, text= "imsi_val[2]")
        self.label_imsi_val_3.grid(row=self.imsi_val_3_row)
        self.imsi_val_3_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_3_text, validate="key", validatecommand=vcmd).grid(row=2, column=1)

        self.label_imsi_val_4 = Label (self.root, text= "imsi_val[3]")
        self.label_imsi_val_4.grid(row=self.imsi_val_4_row)
        self.imsi_val_4_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_4_text, validate="key", validatecommand=vcmd).grid(row=3, column=1)

        self.label_imsi_val_5 = Label (self.root, text= "imsi_val[4]")
        self.label_imsi_val_5.grid(row=self.imsi_val_5_row)
        self.imsi_val_5_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_5_text, validate="key", validatecommand=vcmd).grid(row=4, column=1)

        self.label_imsi_val_6 = Label (self.root, text= "imsi_val[5]")
        self.label_imsi_val_6.grid(row=self.imsi_val_6_row)
        self.imsi_val_6_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_6_text, validate="key", validatecommand=vcmd).grid(row=5, column=1)

        self.label_imsi_val_7 = Label (self.root, text= "imsi_val[6]")
        self.label_imsi_val_7.grid(row=self.imsi_val_7_row)
        self.imsi_val_7_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_7_text, validate="key", validatecommand=vcmd).grid(row=6, column=1)

        self.label_imsi_val_8 = Label (self.root, text= "imsi_val[7]")
        self.label_imsi_val_8.grid(row=self.imsi_val_8_row)
        self.imsi_val_8_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_8_text, validate="key", validatecommand=vcmd).grid(row=7, column=1)


        self.label_imsi_val_9 = Label (self.root, text= "imsi_val[8]")
        self.label_imsi_val_9.grid(row=self.imsi_val_9_row)
        self.imsi_val_9_text = StringVar()
#         self.imsi_val_1_text.set('ffff')
        Entry(self.root, textvariable=self.imsi_val_9_text, validate="key", validatecommand=vcmd).grid(row=8, column=1)

        self.label_imsi_val_10 = Label (self.root, text= "imsi_val[9]")
        self.label_imsi_val_10.grid(row=self.imsi_val_10_row)
        self.imsi_val_10_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_10_text, validate="key", validatecommand=vcmd).grid(row=9, column=1)
        
        self.label_imsi_val_11 = Label (self.root, text= "imsi_val[10]")
        self.label_imsi_val_11.grid(row=self.imsi_val_11_row)
        self.imsi_val_11_text = StringVar()
        Entry(self.root, textvariable=self.imsi_val_11_text, validate="key", validatecommand=vcmd).grid(row=10, column=1)

#.........这里部分代码省略.........
开发者ID:hlf0312,项目名称:python,代码行数:103,代码来源:imsi_mon_demo.py

示例2: EngineGui

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import register [as 别名]
class EngineGui():
    def __init__(self, communicationProtocal):
        self.communicationProtocal = communicationProtocal

    def StartGui(self):
        self.tkRoot = Tk(baseName="")
        self.tkRoot.geometry("350x300+0+0")
        self.tkRoot.title("Engine SAPI GUI")
        self.GUIVisible = True

        frame = Frame(self.tkRoot)
        frame.style = Style()
        frame.style.theme_use("alt")
        frame.pack(fill=BOTH, expand=1)

        frame.columnconfigure(1, weight=1)
        frame.columnconfigure(7, pad=7)
        frame.rowconfigure(13, weight=1)
        frame.rowconfigure(13, pad=7)
        
        Label(frame, text="Start:").grid(row = 0, column=0)
        self.labelStart = Label(frame, text="0")
        self.labelStart.grid(row = 1, column=0)

        Label(frame, text="Length:").grid(row = 0, column=1)
        self.labelLength = Label(frame, text="0")
        self.labelLength.grid(row = 1, column=1)

        Label(frame, text="Total:").grid(row = 0, column=2)
        self.labelTotal = Label(frame, text="0")
        self.labelTotal.grid(row = 1, column=2)
        
        self.labelSentenceLeft = Label(frame, text="...")
        self.labelSentenceLeft.grid(row = 2, column=0, sticky=E)
        self.labelSentenceSpoken = Label(frame, text="...", foreground="red")
        self.labelSentenceSpoken.grid(row = 2, column=1)
        self.labelSentenceRight = Label(frame, text="...")
        self.labelSentenceRight.grid(row = 2, column=2, sticky=W, columnspan=2)   

        scrollbar = Scrollbar(frame, orient=VERTICAL)
        self.labelQueueToSpeak = Label(frame, text="Queue to speak:").grid(row = 3, column=0, pady=4, padx=5, sticky=W)
        self.listboxQueueToSpeak = Listbox(frame, width=50, height=3, yscrollcommand=scrollbar.set)
        
        scrollbar.config(command=self.listboxQueueToSpeak.yview)
        self.listboxQueueToSpeak.grid( sticky=N+S+E+W, row = 4, column = 0, columnspan = 2 ,rowspan = 3, padx=3)
        scrollbar.grid(sticky=N+S+W, row = 4, column = 2, rowspan = 3)

        self.buttonPauze = Button(frame, text="Pauze", command=self.communicationProtocal.handlePauze)
        self.buttonPauze.grid(row = 4, column=3)

        self.buttonStop = Button(frame, text="Stop", command=self.communicationProtocal.restartProcess)
        self.buttonStop.grid(row = 5, column=3)

        self.buttonResume = Button(frame, text="Resume", command=self.communicationProtocal.handleResume)
        self.buttonResume.grid(row = 6, column=3)

        Label(frame, text="Text to say:").grid(row = 7, column=0, padx=3, sticky=W)

        self.stringVarTextToSay = StringVar()
        self.entryTextToSay = Entry(frame, textvariable=self.stringVarTextToSay, width=500)
        self.entryTextToSay.grid(row=8, column=0, columnspan=3, padx=3, sticky=W)
        self.stringVarTextToSay.set("Hello SAPI Speak Engine")
        self.entryTextToSay.bind('<Return>', self.CallBackReturnSay)

        self.buttonSay = Button(frame, text="Say", command=self.CallBackButtonSay)
        self.buttonSay.grid(row = 8, column=3)

        Label(frame, text="Recover action:").grid(row = 9, column=0, padx=3, sticky=W)
        self.recoverActionLabelText = "None"
        self.labelRecoverAction = Label(frame, text=self.recoverActionLabelText, foreground="blue")
        self.labelRecoverAction.grid(row = 10, column=0)   

        Label(frame, text="Voice speed:").grid(row = 9, column=1, sticky=W)
        self.buttonSpeedDown = Button(frame, text="Speed down", command=self.communicationProtocal.handleSpeedDown)
        self.buttonSpeedDown.grid(row = 10, column=1, padx=3, sticky=E)

        self.speedValue = 0
        self.intVarSpeed = IntVar()
        vcmd = (self.tkRoot.register(self.OnValidateEntrySpeakSpeed), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')
        self.entrySpeakSpeed = Entry(frame, textvariable=self.intVarSpeed, validate="key", validatecommand=vcmd, width=5)
        self.entrySpeakSpeed.grid(row=10,column=2)
        self.entrySpeakSpeed.bind('<Return>', self.CallBackSetSpeed)

        self.buttonSpeedUp = Button(frame, text="Speed up", command=self.communicationProtocal.handleSpeedUp)
        self.buttonSpeedUp.grid(row = 10, column=3)

        Label(frame, text="voice:").grid(row = 11, column=0, padx=3, sticky=W)
        self.buttonPrevVoice = Button(frame, text="Prev voice", command=self.communicationProtocal.handlePrevVoice)
        self.buttonPrevVoice.grid(row = 12, column=0, padx=3, sticky=W)

        self.buttonNextVoice = Button(frame, text="Next voice", command=self.communicationProtocal.handleNextVoice)
        self.buttonNextVoice.grid(row = 12, column=3)

        self.currentVoice = StringVar(self.tkRoot)
        self.currentVoice.set(self.communicationProtocal.CurrentVoiceName)

        engine = pyttsx.init()
        voices = engine.getProperty("voices")
        voiceNames = list()
        for x in xrange(0, len(voices)):
#.........这里部分代码省略.........
开发者ID:tjanpool,项目名称:myDragonflyScripts,代码行数:103,代码来源:Engine.py


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