Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding
I've added some comments about the code in question as well... On Wed, Apr 3, 2013 at 11:45 PM, teslafreque...@aol.com wrote: Hi, I am working with Tkinter, and I have set up some simple code to run: import tkinter import re from tkinter import * If you import everything from tkinter into your top-level namespace, then the import tkinter at the top serves no purpose. global master This 'global master' statement does nothing (and is actually misleading IMO). master = Tk() # Start game Launcher def FormGUI(): master.title(GAME TITLE) SW = master.winfo_screenwidth() / 3.2 SH = master.winfo_screenheight() / 3.2 master.geometry(500x300+%d+%d % (SW, SH)) Label(master,text=game:\nGAME TITLE).pack() Button(master, text=Start game, command=DestroyStart, takefocus=1).pack() master.wm_state(zoom) What is zoom? This variable is not defined. In fact, I get a NameError when I try running your code because of this: Traceback (most recent call last): File test_tk.py, line 38, in module FormGUI() File test_tk.py, line 18, in FormGUI master.wm_state(zoom) NameError: global name 'zoom' is not defined If I change zoom to normal (with quotes), it appears to work (although I'm testing on Linux, not Windows). # Destroy the GUI launcher window upon player starting the game. def DestroyStart(): global master master.destroy() master = Tk() ReformGui() # Form the game's GUI window in full screen. def ReformGui(): master.title(GAME TITLE) SW = master.winfo_screenwidth() SH = master.winfo_screenheight() master.geometry(%dx%d+0+0 % (SW,SH)) master.attributes(-fullscreen, 1) master.configure(bg=black) Label(master, text=\GAME TESTING TEXT\, background=black, foreground=white).pack() FormGUI() master.mainloop() # END OF CODE Everything in this code runs appropriately. The main goal of this code is to open up two windows, one with fixed dimensions, the other with full-screen enabled. My problem is that with the code above, the full-screen window opens up properly, however my taskbar shows over the full-screen. Until I click on the full-screen window, the taskbar will not be hidden. Am I doing something wrong, or is there a better way to create a full-screen window in Tkinter with the taskbar hidden? This sounds to me that your full screen window does not have the focus (i.e., it is not the `active' window). Try adding a master.focus_force() call in the ReformGui function to force it to take focus. Note that focus_force() is often considered 'impolite'---it's akin to that kid that always needs to be the center of attention. Of course it's not as bad as master.grab_set_global :) If your application already has 'focus', then you can use focus_set instead of focus_force. The problem may be that you are destroying the original master window and re-creating another (I typically avoid destroying the root window mid-application). Also as a note, it would be helpful to have some kind of button or something to exit the app or exit fullscreen. I had to Alt-F4 in order to quit your sample program ;). Hope this helps, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding
Thanks a lot for your help, I've implemented the code you suggested and it seems to be functioning properly now. I've cleaned up the code a bit as well. I'll also take into account not destroying the master. Thanks again for your help! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding
On 04/04/2013 14:49, Jason Swails wrote: I've added some comments about the code in question as well... On Wed, Apr 3, 2013 at 11:45 PM, teslafreque...@aol.com mailto:teslafreque...@aol.com wrote: Hi, I am working with Tkinter, and I have set up some simple code to run: import tkinter import re from tkinter import * If you import everything from tkinter into your top-level namespace, then the import tkinter at the top serves no purpose. I don't know whether this applies to the OP's code, but I can think of at least one reason why one would want both import module and from module import* at the top of one's code: monkey patching. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding
On Thu, Apr 4, 2013 at 1:30 PM, Rotwang sg...@hotmail.co.uk wrote: On 04/04/2013 14:49, Jason Swails wrote: I've added some comments about the code in question as well... On Wed, Apr 3, 2013 at 11:45 PM, teslafreque...@aol.com mailto:teslafreque...@aol.com** wrote: Hi, I am working with Tkinter, and I have set up some simple code to run: import tkinter import re from tkinter import * If you import everything from tkinter into your top-level namespace, then the import tkinter at the top serves no purpose. I don't know whether this applies to the OP's code, but I can think of at least one reason why one would want both import module and from module import* at the top of one's code: monkey patching. That was not happening in the OP's code (it actually had no references to tkinter after the initial import). That said, if you change any attributes inside tkinter (by binding names inside tkinter to another object) after the top three lines, those changes will not percolate down to the attributes imported via from tkinter import * -- you would obviously have to do that work before importing the tkinter namespace into the toplevel namespace. I'd be interested to see if there's actually an example where someone does this in a way that would not be done better another way. In any case, it served no purpose in this particular program :). All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding
On 04/04/2013 20:00, Jason Swails wrote: On Thu, Apr 4, 2013 at 1:30 PM, Rotwang sg...@hotmail.co.uk mailto:sg...@hotmail.co.uk wrote: [...] I don't know whether this applies to the OP's code, but I can think of at least one reason why one would want both import module and from module import* at the top of one's code: monkey patching. That was not happening in the OP's code (it actually had no references to tkinter after the initial import). Sure. That said, if you change any attributes inside tkinter (by binding names inside tkinter to another object) after the top three lines, those changes will not percolate down to the attributes imported via from tkinter import * -- you would obviously have to do that work before importing the tkinter namespace into the toplevel namespace. What I had in mind was something like this: # begin module derp.py global_variable = 4 def f(): print('global_variable == %i' % global_variable) # end module derp.py # in the interactive interpreter... import derp from derp import * global_variable = 5 f() global_variable == 4 derp.global_variable = 5 f() global_variable == 5 Off the top of my head I don't know whether there's any purpose to doing that kind of thing with tkinter, but I can conceive that it might be useful for e.g. changing widget default behaviour or something. I'd be interested to see if there's actually an example where someone does this in a way that would not be done better another way. No idea, sorry. -- http://mail.python.org/mailman/listinfo/python-list