Nov-13-2020, 03:20 PM
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.
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.