Python Forum
[Tkinter] GUI Opens Minimized
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] GUI Opens Minimized
#21
I do not think this is related to tkinter. Hiding the tkinter root window is odd, and I remember reading somewhere requesting winfo size for a hidden window can be troublesome, though I cannot find that reference now. But that all appears to work fine and you are only having problems when you add in the browser and the wingui stuff.

I would focus on win32gui or paperclip. It is likely that one of these is affected by the OS or Python version change.
Reply
#22
As I showed earlier in the thread, if I remove the hide, then that weird blank window shows up but the GUI still opens minimized.
Reply
#23
I may be confused about what you mean by "GUI". That weird empty window is what I thought of as the GUI. It starts out blank, but is populated with buttons and entry widgets after getting info from the web browser. By the time it is drawn by the "center()" command it is no longer empty,

There is something named "gui" in your code, but that is just a window displaying the message "Setting up user input".

Which window are you calling "GUI"?
Reply
#24
Not sure how to explain it. What I call the GUI is the window created with all the widgets on it which I THOUGH was the top window but opens minimized ("Do Not Call Interface" is the window title that opens minimized). The blank window that shows when I remove the hide is nothing I intentionally create.
Reply
#25
Unless your "sanitizing" changed things, the blank window becomes what you refer to as the GUI. Remove the withdraw() and run your code. Does the blank window disappear when the GUI window appears?

I removed everything except the tkinter parts. When I run this I see the blank window for a flash then it disappears and the "Do Not Call Interface" window appears.
import tkinter as tk
from tkinter import ttk
 
def getPhoneTray():
    return "Name", "Number", "Date", "Time", "Appointment"
 
def center(win):
    """
    centers a tkinter window
    :param win: the main window or Toplevel window to center
    """
    win.update_idletasks()
    width = win.winfo_width()
    frm_width = win.winfo_rootx() - win.winfo_x()
    win_width = width + 2 * frm_width
    height = win.winfo_height()
    titlebar_height = win.winfo_rooty() - win.winfo_y()
    win_height = height + titlebar_height + frm_width
    x = win.winfo_screenwidth() // 2 - win_width // 2
    y = win.winfo_screenheight() // 2 - win_height // 2
    win.geometry('{}x{}+{}+{}'.format(width, height, x, y))
    win.deiconify()
 
def cancel(top):
    top.quit()
    exit(0)
 
def validatePhone(top):
    return "Number"
 
def msgPanel(msg):
    panel=tk.Toplevel()
    panel.title('Do Not Call Interface')
    panel.geometry('200x100')
    tk.Label(panel,text='').grid(row=0,column=0)
    tk.Label(panel,text=msg).grid(row=1,column=1,columnspan=3)
    panel.update()
    return(panel)
 
top=tk.Tk()
# top.withdraw()
intro=msgPanel('Copy line from Phonetray panel')
if (tk.Toplevel.winfo_exists(intro)==1):
    nme,num,dte,tim,pmam=getPhoneTray()
    if (nme.find('Spam')>=0 or nme.find('Telemarketer')>=0):
        nme='Unavaliable'
    intro.destroy()
else:
    nme='Unknown'
    num=''

gui=msgPanel('Setting up user input')
topWidth=600
topHeight=200
top.title("Do Not Call Interface")
top.geometry(str(topWidth)+'x'+str(topHeight))
top.resizable(False,False)
rw=0
myPhone=tk.StringVar()
tk.Radiobutton(top,text='xxx-xxx-7932',variable=myPhone,value='xxx-xxx-7932').grid(row=rw,column=0,pady=5,columnspan=2)
tk.Radiobutton(top,text='yyy-yyy-6305',variable=myPhone,value='yyy-yyy-6305').grid(row=rw,column=2,pady=5,columnspan=2)
tk.Radiobutton(top,text='zzz-zzz-7477',variable=myPhone,value='zzz-zzz-7477').grid(row=rw,column=4,pady=5,columnspan=2)
myPhone.set('xxx-xxx-7932')
rw+=1
tk.Label(top,text='Phone',justify=tk.LEFT).grid(row=rw,column=0,pady=5,sticky=tk.W)
phone=tk.Entry(top,width=12,justify=tk.LEFT)
phone.grid(row=rw,column=1,pady=5,sticky=tk.W)
phone.insert(0,num)
phone.focus_set()
rw+=1
tk.Label(top,text='Caller Name',justify=tk.LEFT).grid(row=rw,column=0,pady=5,sticky=tk.W)
name=tk.StringVar()
nameEntry=tk.Entry(top,textvariable=name,width=48,justify=tk.LEFT)
nameEntry.grid(row=rw,column=1,pady=5,columnspan=4)
name.set(nme)
rw+=1
tk.Label(top,text='Date',justify=tk.LEFT).grid(row=rw,column=0,pady=5,sticky=tk.W)

tk.Label(top,text='Time',justify=tk.LEFT).grid(row=rw,column=2,pady=5,sticky=tk.W)
now=tk.Entry(top,width=6,justify=tk.LEFT)
now.grid(row=rw,column=3,pady=5,sticky=tk.W)
ampm=tk.IntVar()
now.insert(0,tim)
if (pmam=='AM'):
    ampm.set(1)
else:
    ampm.set(2)
tk.Radiobutton(top,text='AM',variable=ampm,value=1).grid(row=rw,column=4,pady=5,sticky=tk.W)
tk.Radiobutton(top,text='PM',variable=ampm,value=2).grid(row=rw,column=5,pady=5,sticky=tk.W)
rw+=1
selections={}

subject=tk.StringVar()
subjectMatter=ttk.Combobox(top,textvariable=subject,width=53,justify=tk.LEFT)
subjectMatter['state']='readonly'
subjectMatter['values']=list(selections.values())
tk.Label(top,text='Subject',justify=tk.LEFT).grid(row=rw,column=0,pady=5,sticky=tk.W)
subjectMatter.grid(row=rw,column=1,columnspan=5)
subject.set('Unknown')
rw+=1
submitButton=tk.Button(top,text='Submit',command=lambda: validatePhone(top))
submitButton.grid(row=rw,column=2,pady=5,sticky=tk.W)
cancelButton=tk.Button(top,text='Cancel',command=lambda: cancel(top)).grid(row=rw,column=4,pady=5,sticky=tk.W)
center(top)
gui.destroy()
top.mainloop()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] MenuBar hidden when new window opens john8888 5 1,431 Sep-14-2022, 02:32 PM
Last Post: john8888
  [Tkinter] Make A Button That Opens Another Tk() Window That I Have Made Saif133 5 28,323 Jan-20-2017, 08:10 PM
Last Post: scriptso

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020