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


Python Tk.focus_force方法代码示例

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


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

示例1: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
def main():
  root = Tk() # create tkinter window
  root.lower() # send tkinter window to back

  # create main app
  app = App(root)

  # Bring GUI to front # app.master = root
  root.lift() # bring tk window to front if initialization finishes
  root.focus_force() # make tk window active one (so you don't need to click on it for hotkeys to work)
  root.mainloop() # start Tkinter GUI loop
开发者ID:awesomeleo,项目名称:RPLidar-SLAMbot,代码行数:13,代码来源:readLogData.py

示例2: pickaudiofile

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
def pickaudiofile():
    FilePicker = Tk()
    FilePicker.withdraw()  # we don't want a full GUI, so keep the root window from appearing
    FilePicker.focus_force()
    filename = tkFileDialog.askopenfilename(filetypes = [('Wav files', '.wav')])

    # Assert file selected
    if filename == "":
        print("File select canceled.")
        sys.exit(0)

    FilePicker.destroy()  # Destory our TKinter instance

    return filename
开发者ID:markkohdev,项目名称:AudioStitch,代码行数:16,代码来源:TKFileUtils.py

示例3: getsavefilename

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
def getsavefilename():
    FilePicker = Tk()
    FilePicker.withdraw() # we don't want a full GUI, so keep the root window from appearing
    FilePicker.lift()
    FilePicker.focus_force()
    filename = tkFileDialog.asksaveasfilename(defaultextension=".wav")

    if filename == "":
        print("File select canceled.")
        sys.exit(0)

    FilePicker.destroy()  # Destory our TKinter instance

    return filename
开发者ID:markkohdev,项目名称:AudioStitch,代码行数:16,代码来源:TKFileUtils.py

示例4: get_files

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
def get_files(titlestring,filetype = ('.txt','*.txt')):
     
    # Make a top-level instance and hide since it is ugly and big.
    root = Tk()
    root.withdraw()
    
    # Make it almost invisible - no decorations, 0 size, top left corner.
    root.overrideredirect(True)
    root.geometry('0x0+0+0')
#    
    # Show window again and lift it to top so it can get focus,
    # otherwise dialogs will end up behind the terminal.
    root.deiconify()
    root.attributes("-topmost",1)
    root.focus_force()

    filenames = []
     
    filenames = tkFileDialog.askopenfilename(title=titlestring, filetypes=[filetype],multiple='True')
    
    #do nothing if already a python list
    if filenames == "": 
        print "You didn't open anything!"  
        return
    
    root.destroy()
    
    if isinstance(filenames,list):
        result = filenames   
    elif isinstance(filenames,tuple): 
        result = list(filenames)
    else:
        #http://docs.python.org/library/re.html
        #the re should match: {text and white space in brackets} AND anynonwhitespacetokens
        #*? is a non-greedy match for any character sequence
        #\S is non white space
    
        #split filenames string up into a proper python list
        result = re.findall("{.*?}|\S+",filenames)
    
        #remove any {} characters from the start and end of the file names
        result = [ re.sub("^{|}$","",i) for i in result ] 
    result.sort()
    return result
开发者ID:dashamstyr,项目名称:LNCcode,代码行数:46,代码来源:LNC_tools.py

示例5: prompt_gui

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
    def prompt_gui(self, name, propagate_exception = False):
        ''' Returns None if failed to load tkinter or open display.
        (unless propagate_exception == True).'''
        
        ''' I thought about caching and reusing the tkinter instance, but it might be hard
        to properly temporarily exit from mainloop and suspend the application.
        Anyway, it takes like 10ms to restart it.'''
        try:
            from Tkinter import Tk, Label, Frame, Entry, StringVar
            root = Tk()
        except:
            if propagate_exception:
                raise
            return None

        root.title('Enter value for \'%s\':' % name)
        frame = Frame(root)
        frame.pack(fill = 'y', expand = True)

        label = Label(frame, text='Enter value for \'%s\':' % name)
        label.pack(side='left')
        
        var = StringVar()
        entry = Entry(frame, textvariable = var)
        entry.pack(side='left')
        
        result = []
        root.bind('<Return>', lambda ev: (result.append(var.get()), root.destroy()))
        ws = root.winfo_screenwidth()
        hs = root.winfo_screenheight()
        root.geometry('+%d+%d' % (ws * 0.4, hs * 0.4))
        entry.focus()
        
        # If I don't do this then for some reason the window doesn't get focus
        # on the second and following invocations. 
        root.focus_force()

        root.mainloop()
        if not len(result):
            # mimic the behaviour of CLI version
            raise KeyboardInterrupt()
        return result[0]
开发者ID:Vlad-Shcherbina,项目名称:icfpc2013-follow-up,代码行数:44,代码来源:simple_settings.py

示例6: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
def main():
    root = Tk()
    root.title('Video Labeler')
    root.focus_force()
    root.update()
    input_filename = tkFileDialog.askopenfilename(title="Select a video file to label", initialdir=os.path.expanduser('~'))
    if not input_filename:
        sys.exit()
    root.update()
    root.withdraw()

    cmd = ['./ffplay', input_filename, '-vf', 'pad=iw:ih+32']
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=open('/dev/null'))
    csv_output, _ = proc.communicate()

    lines = csv_output.splitlines()

    intervals = {}

    for line in lines:
        if line.startswith('#') or not line:
            continue
        tokens = line.split(',')
        class_name = tokens[0]
        start_time = float(tokens[1])
        duration = float(tokens[2])
        if class_name not in intervals:
            intervals[class_name] = intervaltree.IntervalTree()
        intervals[class_name].add(intervaltree.Interval(start_time, start_time + duration))

    output_json = {}
    for class_name, tree in intervals.items():
        tree.merge_overlaps()
        output_json[class_name] = [{'start': i[0], 'end': i[1]} for i in tree.items()]
    default_filename = os.path.splitext(os.path.basename(input_filename))[0] + '.txt'
    out_filename = tkFileDialog.asksaveasfilename(defaultextension=".txt", initialfile=default_filename,
        message=SAVE_MSG, title=SAVE_MSG)
    if not out_filename:
        sys.exit()
    open(out_filename, 'w').write(json.dumps(output_json, indent=4))
开发者ID:lwneal,项目名称:ffplay-experiments,代码行数:42,代码来源:labeler.py

示例7: set_dir

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import focus_force [as 别名]
def set_dir(titlestring):    
     
    # Make a top-level instance and hide since it is ugly and big.
    root = Tk()
    root.withdraw()
    
    # Make it almost invisible - no decorations, 0 size, top left corner.
    root.overrideredirect(True)
    root.geometry('0x0+0+0')
#    
    # Show window again and lift it to top so it can get focus,
    # otherwise dialogs will end up behind the terminal.
    root.deiconify()
    root.attributes("-topmost",1)
    root.focus_force()
    
    file_path = tkFileDialog.askdirectory(parent=root,title=titlestring)
     
    if file_path != "":
       return str(file_path)
     
    else:
       print "you didn't open anything!"
    
    # Get rid of the top-level instance once to make it actually invisible.
    root.destroy()     
开发者ID:a301-teaching,项目名称:CALIPSOcode,代码行数:28,代码来源:CALIPSO_tools.py


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