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


Python Tk.overrideredirect方法代码示例

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


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

示例1: run_text_editor

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def run_text_editor(filename):
    root = Tk()
    input_handler = user_input.user_input()

    input_handler.start_instance(filename)
    app = text_canvas.text_canvas(root, 12, input_handler, filename)

    root.wm_attributes('-fullscreen', 1)
    root.title('shim')
    root.overrideredirect()

    root.mainloop()
开发者ID:m45t3r,项目名称:shim,代码行数:14,代码来源:shim.py

示例2: open_main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def open_main():
    btn_dims = int(settings["gui"]["btn_dims"])
    _xt_root = Tk()
    if settings["gui"]["bypass_wm"] == "1":
        _xt_root.overrideredirect(1)
    _xt_root.title("Xtouchy Toolbox")
    _xt_root.maxsize(btn_dims * 3, btn_dims * 3)
    root_frame = ttk.Frame(_xt_root, padding="0 0 0 0", width=btn_dims * 3, height=btn_dims * 3)
    root_frame.grid(column=1, row=0, sticky=("N", "W", "E", "S"))
    # Screen orientation
    wrkbtn = ttk.Button(root_frame, width=2, text="↑", command=lambda: rotate(0, _xt_root))
    wrkbtn.place(x=btn_dims, y=0, width=btn_dims, height=btn_dims)
    wrkbtn = ttk.Button(root_frame, width=2, text="↓", command=lambda: rotate(2, _xt_root))
    wrkbtn.place(x=btn_dims, y=btn_dims * 2, width=btn_dims, height=btn_dims)
    wrkbtn = ttk.Button(root_frame, width=2, text="←", command=lambda: rotate(1, _xt_root))
    wrkbtn.place(x=0, y=btn_dims, width=btn_dims, height=btn_dims)
    wrkbtn = ttk.Button(root_frame, width=2, text="→", command=lambda: rotate(3, _xt_root))
    wrkbtn.place(x=btn_dims * 2, y=btn_dims, width=btn_dims, height=btn_dims)
    # Close/Move button
    mvbtn = ttk.Button(root_frame, width=2, text="⇱")
    mvbtn.bind("<B1-Motion>", lambda x: move(x, _xt_root))
    mvbtn.place(x=0, y=0, width=btn_dims, height=btn_dims)
    ttk.Button(root_frame, width=2, text="X", command=lambda: reset_and_exit(_xt_root)).place(
        x=btn_dims * 2, y=0, width=btn_dims, height=btn_dims
    )
    # Toggle virtual keyboard
    tvkbtn = ttk.Button(root_frame, width=2, text="K")
    tvkbtn.bind("<B1-Motion>", lambda x: move_vkeyboard(x, _xt_root))
    tvkbtn.place(x=0, y=btn_dims * 2, width=btn_dims, height=btn_dims)
    _xt_root.mainloop()
开发者ID:ChlorideCull,项目名称:xtouchy,代码行数:32,代码来源:xtouchy-toolbox.py

示例3: SelectDataFiles

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def SelectDataFiles():
    """Select the files to compress into a JAM"""
    # Draw (then withdraw) the root Tk window
    logging.info("Drawing root Tk window")
    root = Tk()
    logging.info("Withdrawing root Tk window")
    root.withdraw()

    # Overwrite root display settings
    logging.info("Overwrite root settings to basically hide it")
    root.overrideredirect(True)
    root.geometry('0x0+0+0')

    # Show window again, lift it so it can recieve the focus
    # Otherwise, it is behind the console window
    root.deiconify()
    root.lift()
    root.focus_force()

    # The files to be compressed
    jam_files = filedialog.askdirectory(
        parent=root,
        title="Where are the extracted LEGO.JAM files located?"
    )

    if not jam_files:
        root.destroy()
        colors.text("\nCould not find a JAM archive to compress!",
                    color.FG_LIGHT_RED)
        main()

    # Compress the JAM
    root.destroy()
    BuildJAM(jam_files)
开发者ID:le717,项目名称:PatchIt,代码行数:36,代码来源:legojam.py

示例4: selecttheIsland

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def selecttheIsland():
    """Manually select a LEGO Island installation if detection fails."""
    # Draw (then withdraw) the root Tk window
    root = Tk()
    root.withdraw()
    root.overrideredirect(True)
    root.geometry('0x0+0+0')
    root.deiconify()
    root.lift()
    root.focus_force()

    # Select the exe
    logging.info("Display file selection dialog for LEGO Island exe")
    manualGamePath = filedialog.askopenfilename(
        parent=root,
        title="Select your LEGO Island Executable (LEGOISLE.EXE)",
        defaultextension=".exe",
        filetypes=[("Windows Executable", "*.exe")]
    )

    # The user clicked the cancel button
    if not manualGamePath:
        # Give focus back to console window
        root.destroy()

        logging.warning("User did not select a LEGO Island installation!")
        print("\nCould not find a vaild LEGO Island installation!")
        main()

    # The user selected an installation
    else:
        try:
            # Display exit message
            logging.info("Display exit message")
            print("\nSee ya later, Brickulator!")

            logging.info("Run user-defined installation, located at {0}"
                         .format(manualGamePath))
            subprocess.call([manualGamePath])

            # Close app
            logging.info("{0} is shutting down".format(appName))
            raise SystemExit(0)

        # TODO I guess this works?
        except Exception:
            logging.warning("User-defined LEGO Island installation did not work!")
            print("\nCould not run {0} from {1}!".format(game, manualGamePath))

            logging.info("Re-running manual installation process")
            print("\nPlease select a new {0} installation".format(game))
            time.sleep(2)
            selecttheIsland()
开发者ID:le717,项目名称:ICU-Windower,代码行数:55,代码来源:ICUWindower.py

示例5: SelectJAMArchive

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def SelectJAMArchive():
    """Select the JAM Archive to extract"""
    # Draw (then withdraw) the root Tk window
    logging.info("Drawing root Tk window")
    root = Tk()
    logging.info("Withdrawing root Tk window")
    root.withdraw()

    # Overwrite root display settings
    logging.info("Overwrite root Tk window settings to hide it")
    root.overrideredirect(True)
    root.geometry('0x0+0+0')

    # Show window again, lift it so it can receive the focus
    # Otherwise, it is behind the console window
    root.deiconify()
    root.lift()
    root.focus_force()

    # Select the LEGO Racers installation
    logging.info("Where is the JAM archive to be extracted located?")
    jam_location = filedialog.askopenfilename(
        parent=root,
        title="Where is LEGO.JAM",
        defaultextension=".JAM",
        filetypes=[("LEGO.JAM", "*.JAM")]
    )

    if not jam_location:
        root.destroy()
        colors.text("\nCould not find a JAM archive to extract!",
                    color.FG_LIGHT_RED)
        main()

    # Extract the JAM
    root.destroy()
    ExtractJAM(jam_location)
开发者ID:le717,项目名称:PatchIt,代码行数:39,代码来源:legojam.py

示例6: SelectPiInstall

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def SelectPiInstall():
    """Searches or asks for user's PatchIt! installation"""
    # Used to detect if user needs to manually define an installation
    found_install = False

    # Path to check for PatchIt! on Windows x64
    x64_path = os.path.join(os.path.expandvars("%ProgramFiles(x86)%"), "PatchIt")

    # Path to check for PatchIt! on Windows x86
    x86_path = os.path.join(os.path.expandvars("%ProgramFiles%"), "PatchIt")

    # Perhaps the Updater is in the same place as PatchIt!.
    # In that case, use a different method for finding the installation
    same_path = os.path.join(os.path.dirname(app_folder), "Settings")

    # The updater resides in the same location as PatchIt!
    if os.path.exists(same_path):
        # It's been found, no need for user to define it
        found_install = True
        # Write the installation to file
        SavePiInstall(os.path.dirname(app_folder))

    # If this is x64 Windows, look for PatchIt in Program Files (x86)
    if os_bit:
        if os.path.exists(os.path.join(x64_path, "PatchIt.exe")):
            # It's been found, no need for user to define it
            found_install = True
            # Write the installation to file
            SavePiInstall(x64_path)

    # If this is x86 Windows, look for PatchIt in Program Files
    else:
        if os.path.exists(os.path.join(x86_path, "PatchIt.exe")):
            # It's been found, no need for user to define it
            found_install = True
            # Write the installation to file
            SavePiInstall(x86_path)

    if not found_install:
        print(
            """Could not find a valid PatchIt! installation!
Please select your PatchIt! installation."""
        )

        # Draw (then withdraw) the root Tk window
        root = Tk()
        root.withdraw()

        # Overwrite root display settings
        root.overrideredirect(True)
        root.geometry("0x0+0+0")

        # Show window again, lift it so it can receive the focus
        # Otherwise, it is behind the console window
        root.deiconify()
        root.lift()
        root.focus_force()

        # Select PatchIt.exe
        pi_path = filedialog.askopenfilename(
            parent=root, title="Where is PatchIt.exe", defaultextension=".exe", filetypes=[("PatchIt.exe", "*.exe")]
        )

        # Give focus back to console window
        root.destroy()

        # Get the directory PatchIt! is in
        pi_path = os.path.dirname(pi_path)

        # The user clicked the cancel button
        if pi_path:
            # Write the installation to file
            SavePiInstall(pi_path)
开发者ID:le717,项目名称:PatchIt,代码行数:75,代码来源:PiUpdater.py

示例7: take_screenshot_crop

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def take_screenshot_crop(path):
    pimage = _r.take_screenshot()

    _, _, width, height = pimage.getbbox()

    displays = _r.get_display_monitors()
    leftmost, topmost = 0, 0
    for d in displays:
        if d[0] < leftmost:
            leftmost = d[0]
        if d[1] < topmost:
            topmost = d[1]

    root = Tk()  # Creates a Tkinter window
    root.overrideredirect(True)  # Makes the window borderless
    root.geometry("{0}x{1}+{2}+{3}".format(width, height, leftmost, topmost))  # window size = screenshot size
    root.config(cursor="crosshair")  # Sets the cursor to a crosshair

    pimage_tk = ImageTk.PhotoImage(pimage)  # Converts the PIL.Image into a Tkinter compatible PhotoImage

    can = Canvas(root, width=width, height=height)  # Creates a canvas object on the window
    can.pack()
    can.create_image((0, 0), image=pimage_tk, anchor="nw")  # Draws the screenshot onto the canvas

    # This class holds some information about the drawn rectangle
    class CanInfo:
        rect = None
        startx, starty = 0, 0

    # Stores the starting position of the drawn rectangle in the CanInfo class
    def xy(event):
        CanInfo.startx, CanInfo.starty = event.x, event.y

    # Redraws the rectangle when the cursor has been moved
    def capture_motion(event):
        can.delete(CanInfo.rect)
        CanInfo.rect = can.create_rectangle(CanInfo.startx, CanInfo.starty, event.x, event.y)

    # Cancels screen capture
    def cancel(event):
        if event.keycode == 27:  # cancel when pressing ESC
            root.destroy()

    # Saves the image when the user releases the left mouse button
    def save_img(event):
        startx, starty = CanInfo.startx, CanInfo.starty
        endx, endy = event.x, event.y

        # Puts the starting point in the upper left and the ending point in the lower right corner of the rectangle
        if startx > endx:
            startx, endx = endx, startx
        if starty > endy:
            starty, endy = endy, starty

        crop_image = pimage.crop((startx, starty, endx, endy))
        crop_image.save(path, "PNG")
        root.destroy()  # Closes the Tkinter window

    # Binds mouse actions to the functions defined above
    can.bind("<KeyPress>", cancel)
    can.bind("<Button-1>", xy)
    can.bind("<B1-Motion>", capture_motion)
    can.bind("<ButtonRelease-1>", save_img)

    can.focus_force() # Force focus of capture screen
    root.mainloop()  # Shows the Tk window and loops until it is closed
开发者ID:instantshare,项目名称:instantshare,代码行数:68,代码来源:windows_tk.py

示例8: RectSelCanvas

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
    
    canvas  = RectSelCanvas(root, cursor='crosshair')
    canvas.pack(fill='both', expand='yes')
    
    image           = ImageGrab.grab()
    photoImage      = PhotoImage(image)
    canvas['borderwidth']   = 0
    canvas.create_image((0, 0), anchor='nw', image=photoImage)   
    
    class Observer:
        def __init__(self, root, image):
            self.__image    = image
            self.__root     = root
        
        def update(self, *box):
            cropImage   = self.__image.crop(box)
            filename = asksaveasfilename(defaultextension='.png', filetypes=[('PNG Image', '*.png'), ('JPEG Image', '*.jpg')])
            if filename != '':
                cropImage.save(filename)
            root.quit()
            
    canvas.add_observer(Observer(root, image))
    
    w, h = root.winfo_screenwidth(), root.winfo_screenheight()
    root.overrideredirect(1)
    root.geometry("%dx%d+0+0" % (
        root.winfo_screenwidth(), root.winfo_screenheight()
    ))    
    
    root.mainloop()
开发者ID:xialulee,项目名称:WaveSyn,代码行数:32,代码来源:screenshot.py

示例9: LRWriteSettings

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import overrideredirect [as 别名]
def LRWriteSettings():
    """Write PatchIt! LEGO Racers settings"""
    # Draw (then withdraw) the root Tk window
    logging.info("Drawing root Tk window")
    root = Tk()
    logging.info("Withdrawing root Tk window")
    root.withdraw()

    # Overwrite root display settings
    logging.info("Overwrite root Tk window settings to hide it")
    root.overrideredirect(True)
    root.geometry('0x0+0+0')

    # Show window again, lift it so it can receive the focus
    # Otherwise, it is behind the console window
    root.deiconify()
    root.lift()
    root.focus_force()

    # Select the LEGO Racers installation
    logging.info("Display folder dialog for LEGO Racers installation")
    new_racers_game = filedialog.askopenfilename(
        parent=root,
        title="Where is LEGORacers.exe",
        defaultextension=".exe",
        filetypes=[("LEGORacers.exe", "*.exe")]
    )

    # Get the directory the Exe is in
    new_racers_game = os.path.dirname(new_racers_game)

    # The user clicked the cancel button
    if not new_racers_game:
        # Give focus back to console window
        logging.info("Give focus back to console window")
        root.destroy()

        # Go back to the main menu
        logging.warning("User did not select a new LEGO Racers installation!")
        PatchIt.main()

    # The user selected a folder
    else:
        logging.info("User selected a new LEGO Racers installation at {0}"
                     .format(new_racers_game))

        # Give focus back to console window
        logging.info("Give focus back to console window")
        root.destroy()

        # Create Settings directory if it does not exist
        logging.info("Creating Settings directory")
        if not os.path.exists(const.settings_fol):
            os.mkdir(const.settings_fol)

        # Write settings, using UTF-8 encoding
        logging.info("Open 'Racers.cfg' for writing using UTF-8-NOBOM encoding")
        with open(os.path.join(const.settings_fol, const.LR_settings),
                  "wt", encoding="utf-8") as racers_file:

            # As partially defined in PatchIt! Dev-log #6
            # (http://wp.me/p1V5ge-yB)
            logging.info("Write line telling what program this file belongs to")
            racers_file.write("// PatchIt! V1.1.x LEGO Racers Settings\n")

            # Write brief comment explaining what the number means
            # "Ensures the first-run process will be skipped next time"
            logging.info("Write brief comment explaining what the number means")
            racers_file.write("# Ensures the first-run process will be skipped next time\n")
            logging.info("Write '1' to line 3 to skip first-run next time")
            racers_file.write("1\n")

            # Run check for 1999 or 2001 version of Racers
            logging.info("Run LRVerCheck() to find the version of LEGO Racers")
            LRVer = LRVerCheck(new_racers_game)

            logging.info("Write brief comment telling what version this is")
            racers_file.write("# Your version of LEGO Racers\n")
            logging.info("Write game version to fifth line")
            racers_file.write(LRVer)

            logging.info("Write brief comment explaining the folder path")
            racers_file.write("\n# Your LEGO Racers installation path\n")
            logging.info("Write new installation path to seventh line")
            racers_file.write(new_racers_game)

        # Log closure of file (although the with handle did it for us)
        logging.info("Closing Racers.cfg")
        logging.info("Proceeding to read LEGO Racers Settings")
        LRReadSettings()
开发者ID:le717,项目名称:PatchIt,代码行数:92,代码来源:Racers.py


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