Python Forum
[Tkinter] tkinter global variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] tkinter global variable
#2
pic is not defined until after you select a file from the file dialog drawn by the function on_openfile() which is called when you select "File" from the file menu. None of that has happened yet when you try to open(pic).

GUI programming is event driven, not linear. Your code responds to actions performed by the user. You got part of this right. You only draw the file dialog when the user has selected "File" from the file menu. You need to use the same paradigm for opening the file. The file dialog needs to call a function when the file is selected. That function is where you will open and read the file.
Reply


Messages In This Thread
tkinter global variable - by chalao_adda - Nov-13-2020, 02:51 PM
RE: tkinter global variable - by deanhystad - Nov-13-2020, 03:20 PM
RE: tkinter global variable - by chalao_adda - Nov-13-2020, 04:08 PM
RE: tkinter global variable - by deanhystad - Nov-13-2020, 06:19 PM
RE: tkinter global variable - by chalao_adda - Nov-14-2020, 04:16 AM
RE: tkinter global variable - by deanhystad - Nov-14-2020, 05:22 AM
RE: tkinter global variable - by chalao_adda - Nov-14-2020, 05:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pass a variable between tkinter and toplevel windows janeik 10 2,333 Jan-24-2024, 06:44 AM
Last Post: Liliana
  [Tkinter] Making entry global in tkinter with multiprocessing luckyingermany 2 2,327 Jan-21-2022, 03:46 PM
Last Post: deanhystad
  [Tkinter] Update variable using tkinter entry methon drSlump 6 5,205 Oct-15-2021, 08:01 AM
Last Post: drSlump
  [Tkinter] tkinter.Menu – How to make text-variable? Sir 3 5,643 Mar-10-2021, 04:21 PM
Last Post: Sir
  Global Variable in Event Function? What am I doing wrong here? p_hobbs 1 3,490 Nov-13-2019, 02:50 PM
Last Post: Denni
  [Tkinter] Unable to Access global Variable when switching between frames tziyong 1 3,470 Nov-03-2019, 01:08 AM
Last Post: balenaucigasa
  [Tkinter] Extrakt a Variable from a closed tkinter window hWp 5 3,776 Aug-23-2019, 09:01 PM
Last Post: woooee
  tkinter - global variable not working albry 2 7,050 Jan-26-2019, 04:22 AM
Last Post: Larz60+
  Variable not sharing same value between two different functions Python 2.7 Tkinter albert 0 2,400 Aug-31-2018, 10:45 AM
Last Post: albert
  printing option menu variable in label in Tkinter SmokerX 1 6,622 Jan-18-2018, 07:36 PM
Last Post: SmokerX

Forum Jump:

User Panel Messages

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