Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42753
| References | <d6635af4-7a4a-4aeb-8eaf-4b13dee7c003@googlegroups.com> |
|---|---|
| Date | 2013-04-04 09:49 -0400 |
| Subject | Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding |
| From | Jason Swails <jason.swails@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.101.1365083379.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
I've added some comments about the code in question as well...
On Wed, Apr 3, 2013 at 11:45 PM, <teslafrequency@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python 3.3 Tkinter Fullscreen - Taskbar not Hiding teslafrequency@aol.com - 2013-04-03 20:45 -0700
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding Jason Swails <jason.swails@gmail.com> - 2013-04-04 09:49 -0400
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding Rotwang <sg552@hotmail.co.uk> - 2013-04-04 18:30 +0100
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding Jason Swails <jason.swails@gmail.com> - 2013-04-04 15:00 -0400
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding Rotwang <sg552@hotmail.co.uk> - 2013-04-04 23:21 +0100
Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding teslafrequency@aol.com - 2013-04-04 10:31 -0700
csiph-web