Python Forum
[Tkinter] question for a tkinter dialog box
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] question for a tkinter dialog box
import tkinter as tk

root = tk.Tk()
logo = tk.PhotoImage(file="python_logo_small.gif")

w1 = tk.Label(root, image=logo).pack(side="right")

explanation = """At present, only GIF and PPM/PGM
formats are supported, but an interface 
exists to allow additional image file
formats to be added easily."""

w2 = tk.Label(root,
              padx = 10,
new to python and tkinter , here a sample code I got in this tutor for tkinter .

So between root = tk.Tk() and root.mainloop() is the code for this dialog box.
My question is w1 and w2 . These are defined but do not understand how they are called to be used in root.mainloop() ?
Yoriz write Aug-24-2021, 10:51 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
You don't have a dialog box. You have a toplevel window.

There are commands for making different kinds of standard dialog boxes.

Or you can make a custom dialog box:

As an aside, you do not have w1 and w2. w1 and w2 are both None because that is the value returned by pack().

If you are asking how widgets appear in windows, that happens when the window is drawn. When you call root.mainloop() the first thing it does is draw the root window. Because you packed two labels in the root window, the labels are positioned and the root window grows to accommodate. If you had buttons or other interactive controls the root.mainloop() would process button and key press events.
deanhystad, thanks for the reply
I been using POWERBASIC for a long time. Hope to duplicate everything to python. I have a long way to go. Python does not have good support for printing to printer so will use powerbasic for that. dll or exe.

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] cancelling open dialog gives empty string rwahdan 2 825 Jul-17-2021, 09:17 PM
Last Post: steve_shambles
  Python tkinter question tablet Nick_tkinter 8 1,988 Mar-04-2021, 10:44 PM
Last Post: Larz60+
  tkinter slider question Nick_tkinter 1 900 Feb-22-2021, 01:31 PM
Last Post: deanhystad
  [Tkinter] Noob question:Using pyttsx3 with tkinter causes program to stop and close, any ideas? Osman_P 4 2,758 Nov-14-2020, 10:51 AM
Last Post: Osman_P
  [PyQt] Received RunTimeError after script concludes, closing Dialog Window (clicking x-out) skipper0802 0 1,190 Oct-09-2020, 09:23 PM
Last Post: skipper0802
  question on tkinter canvas PhotoImage gr3yali3n 1 976 Sep-05-2020, 12:18 PM
Last Post: Larz60+
  Tkinter parameter question DPaul 2 1,012 Mar-14-2020, 09:35 AM
Last Post: DPaul
  Newbie question with Tkinter Entry mariolopes 2 1,245 Oct-12-2019, 11:02 PM
Last Post: Larz60+
  [WxPython] Return code when closing the dialog ioprst 1 1,824 Aug-13-2019, 11:47 AM
Last Post: jefsummers
  PyQT5 : Unable to Create Another Dialog While One is Open iMuny 3 1,821 Jul-17-2019, 11:40 AM
Last Post: iMuny

Forum Jump:

User Panel Messages

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