Change app icon while using tkinter (Python 3.6 MacOS) - python

Here is a little window I made practising tkinter and I know how to change the icon next to the title as I did in code, but I would like some help changing the app icon in my MacOS dock because right now it is the python launcher icon. If anyone could help me that would be great. Also, I know there is nothing in the windows but I don't need that at the moment.
#Import the tkinter module
import tkinter
#Create a window
window = tkinter.Tk()
#Title the window
window.title("Welcome to ECS, we are excited to have you in class")
#Change the window size
window.geometry("400x100")
#Icon next to the title
window.wm_iconbitmap('33mm33.icns')
#Here is where I would like to be able to change the application icon
#Draw the windows and start the application
window.mainloop()

Related

Make Tkinter window window full screen, and make it show taskbar, even though it has no titlebar

I am trying to make a Tkinter app, and it has no title bar.
I have added revisability with size grip, moving the window around and minimizing
However, I am trying to make the Tkinter window full sized, AND SHOW THE TASKBAR
here is my code
def funel():
root.overrideredirect(False)
root.state('zoomed')
root.overrideredirect(True)
messagebox.showerror("This feature is not added yet", "This feature is not added yet. Please give me help")
fullscreen_btn.bind("<Button-1>", lambda event: funel_exit())
So yeah... it Fullscreen's, however it does hide the taskbar. I WANT THE TASKBAR NOT TO BE HIDDEN
if my question aint clear, please inform.

Tkinter window with overrideredirect randomly pops up when any other application is opened

I've been trying to make use of the overrideredirect() function in tkinter, but I'm facing a small issue.
Here's a sample code snippet:
from tkinter import *
root = Tk()
root.geometry("500x500+200+200")
root.overrideredirect(True)
mainloop()
Here when I press Window + D the window minimizes like it's supposed to, but if I restore any minimized app or open a new application (like Chrome), the tkinter window gets restored too instead of staying minimized.
Is there any way to fix this problem? It would be great if anyone could help me out.

why tkinter will resize the windows when I open the another pyqt5 windows?

StackOverflow.
why the Tkinter windows will resize when I use Tkinter open another pyqt5 window?
here is my code:
tk.Button(self.frame, text="start", fg="white", bg="#708090",command=lambda: MyThread(self.test)).place(x=15,y=265,relwidth = 0.18,relheight=0.09)
def test(self):
app = QApplication(sys.argv)
win_root = MainWindows()
win_root.show()
sys.exit(app.exec_())
I need to use pyqt5's Module like QtWebEngineWidgets, but I don't want to rewrite my program use pyqt5, so I try to use tk.Button to open the pyqt5 windows, it works, but I don't know why the Tkinter windows will resize its windows. The original size is 500x500, but it will be 300x300 when open pyqt5 windows.
Thanks!!!

Tkinter partially click through-able? (Windows only)

I am writing an application that hovers a ruler over all other on-screen content. I have made the tkinter window and associated canvas transparent using:
root.overrideredirect(True) #This hides the window outline/controls
root.state('zoomed') #This scales the window to fill the page
root.configure(background=bgColor) #Set bg color of window (used to make transparent \/)
root.wm_attributes("-transparentcolor", bgColor) #Necessary for transparent, window
root.lift()#Lifting window above all others
root.wm_attributes("-topmost", True)#Hold window on top of all other windows
I am able to click through this application where transparent before compiling with pyinstaller to an exe. However after compiling to an exe this is no longer possible.
I attempted the solution shared here: Tkinter see through window not affected by mouse clicks
However this makes the entire window click through-able, meaning that I can no longer interact with the non-transparent portions of the top window (which I have to be able to do).
hwnd = win32gui.FindWindow(None, "Digital Ruler") # Getting window handle
# hwnd = root.winfo_id() getting hwnd with Tkinter windows
# hwnd = root.GetHandle() getting hwnd with wx windows
lExStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
lExStyle |= win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED
win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE , lExStyle )
I need to be able to move/interact with any colored sections of the root window but need to be able to click through any transparent sections... So far I have only been able to completely seize the mouse or completely miss it.
I also have met this problem...
after a lot try, I found that if distribute the exe file with the manifest file which also generated by pyinstaller, the click through feature will work as expected.

Tkinter window with both title bar and windows taskbar

I have searched wide and far for this question, but noone seems to know. I create a simple tkinter window (tcl 8.5) in python 2.7 and want it maximized, just as if I would hit the maximize button in top right corner. Using the -fullscreen option is not an option since it removes the title bar.
I tried the following:
import Tkinter
root = Tkinter.Tk()
root.overrideredirect(True)
# Set window to be size of screen
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
The problem is that the window is now below the Windows taskbar and some of my elements are therefore not shown. An easy hack would be to set height to screenheight-some_constant, or calculate some_constant based on data from the operating system. However, this seems like an extremely ugly hack.
Is there any way to maximize a window in tkinter in a clean way where the window is above the (Windows) taskbar and still has a title bar?
i know this is an old question but i have tested the following code on an XP system (32bit) with python 2.7.6, using TCL version 8.5 and tk version 8.5.
code:
import Tkinter as tk
root = tk.Tk()
root.state("zoomed")
root.mainloop()
this does start the window maximised on the primary monitor.
it does have pitfalls - i have been unable to make it maximise on another monitor, but does work reliably without covering the title bar or taskbar.
and as you want to keep the title bar i would leave out the overrideredirect.

Categories