Python Forum
tkinter GUI, problem running seperate files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter GUI, problem running seperate files
#11
One thing I saw was this error:
Error:
line 75, in <lambda> command=lambda: controller.show_frame(PageFour))
briefly searched your classes and found no class or function controller you are requiring it in all the page inits but not supplying.? PageFour is a class and in show_frame you're looking for an integer or count??
Reply
#12
(Sep-25-2019, 05:16 PM)joe_momma Wrote: One thing I saw was this error:
Error:
line 75, in <lambda> command=lambda: controller.show_frame(PageFour))
briefly searched your classes and found no class or function controller you are requiring it in all the page inits but not supplying.? PageFour is a class and in show_frame you're looking for an integer or count??

That lambda command is on a button in the StartPage class and link to a new window. Not sure if that answered your question, as I'm a newbie. Displayed in the pictures under.

[Image: 83403xcbd80]

[Image: 83404xdc7fe]
Reply
#13
No that was a pretty straight forward explanation -- now I cannot tell you exactly what is happening per-sae but I can tell you what it sounds like to me -- the python/pyqt platform that the interpreted python/pyqt code runs on is some how getting applied to your initial call but then when you make that outside call to another *.py file (?? which I do not understand why your are doing that without having imported it into your main program) that is not getting brought properly onto the python/pyqt platform -- possibly because its not designed to do that or if it is will probably require something special to do so -- now if you are running from within (or upon) the python/pyqt platform (via say a terminal emulator and having typed the "python" command) and you start your program from there yes it may work because everything you call will be placed upon that platform automatically

Still this brings us back to that question -- why are you accessing exterior *.py files from within a *.py program instead of importing that *.py file and then referencing the code within that file?
Reply
#14
From the results of the test I gave you, it looks like the problem has to do with page 6.
Are you posting the complete error traceback, verbatim? I was expecting to see some line numbers.
Reply
#15
(Sep-25-2019, 09:32 PM)Denni Wrote: Still this brings us back to that question -- why are you accessing exterior *.py files from within a *.py program instead of importing that *.py file and then referencing the code within that file?

The reason is that I haven't figured out how to import and run scripts I wrote myself. I tried several different solutions from forums, but it doesn't seem to work. Do you have any advice for me on how I would go about doing that? Maybe that solves my problem!

Thank you in advance

(Sep-26-2019, 12:42 AM)Larz60+ Wrote: From the results of the test I gave you, it looks like the problem has to do with page 6.
Are you posting the complete error traceback, verbatim? I was expecting to see some line numbers.

I pasted the entire error traceback, no lines were listed like it normally does. I will look over the code in class PageSix and see if I can find any mistakes. Like I stated in the beginning, I'm very new to programming and probably do many things the "wrong" way.

Thank you for the help so far!
Reply
#16
Okay let us say we wrote a Class with all its imports it needs such as this

from PyQt5.Widgets import QWidget, QLabel

class Exterior(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.lblTest = QLabel(Test)
***************************************************
Okay that is our class (called Test.py) outside our main program (called Main.py) we are writing now to import we need to do a few things (note the sub-directory is not necessary but it makes things cleaner)

Create a subfolder within your Main area call it say Utils so we have the following folder/file structure:
Main
    Utils
        Test.py
    Main.py
Now we have our Main program and our Test class that we want to import but just importing it will not work but why? Well because python requires this interesting little additive which we implement by creating an empty text file and renaming it to "__init__.py" then placing one within our Main folder and one within our Utils folder as follows:
Main
    Utils
        __init__.py
        Test.py
    __init__.py
    Main.py
Now within Main.py we can add the following code and import Test into Main

import Utils.Exterior as Ext
And reference its contents (with using the above import) like this:
    Ext.lblTest.setText('My Test')
Now that above bit of code will appear to do nothing if implemented as designed since we never show lblTest anywhere but that will set the value you just wont be able to see it. Still what the above does do is show you how to set up and import an exterior class into your current code base.
Reply
#17
(Sep-27-2019, 02:10 PM)Denni Wrote: Okay let us say we wrote a Class with all its imports it needs such as this

Your solution solved my problem! I don't understand why yet though.

Thank you so much for your help :)
Reply
#18
Okay so which part about it do you not understand?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Help running a loop inside a tkinter frame Konstantin23 3 1,563 Aug-10-2023, 11:41 AM
Last Post: Konstantin23
  Why is the program not running? Is there a logical or syntax problem? behi00 10 2,116 Apr-01-2023, 12:50 AM
Last Post: woooee
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 5,006 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  Python3 tkinter radiobutton problem Nick_tkinter 14 5,999 Feb-15-2021, 11:01 PM
Last Post: Nick_tkinter
  tkinter python button position problem Nick_tkinter 3 3,557 Jan-31-2021, 05:15 AM
Last Post: deanhystad
  [Tkinter] ClockIn/Out tkinter problem Maryan 2 2,199 Oct-12-2020, 03:42 AM
Last Post: joe_momma
  tkinter| listbox.insert problem Maryan 3 3,500 Sep-29-2020, 05:34 PM
Last Post: Yoriz
  Tkinter problem DPaul 6 4,113 May-28-2020, 03:40 PM
Last Post: DPaul
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 2,575 Apr-17-2020, 08:12 PM
Last Post: johnjh
  [Tkinter] Problem with tkinter when creating .exe file Jan_97 2 4,588 Feb-27-2020, 05:17 PM
Last Post: Jan_97

Forum Jump:

User Panel Messages

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