Python Forum
[PyQt] [Solved]Add a SpinBox to MsgBox or Carry Variable Over?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] [Solved]Add a SpinBox to MsgBox or Carry Variable Over?
#3
Thanks for the suggestion. I'll nest my CheckoutPopup (spindemo) inside my main code if I have to, but I'm wondering if it's possible to take a variable from my AdminMenu.py and use it in my CheckoutPopup.py?

I'm trying to take the "name" variable (or TestVariable) and bring it over to my CheckoutPopup.py

Is there a way to carry the variable over to the other code or is it just better to have the CheckoutPopup nested inside my AdminMenu.py?

Snippet from AdminMenu.py
    def getCellText(self):
        if self.InventoryDisplay.selectedIndexes():
            item = self.InventoryDisplay.selectedIndexes()[0]
            row = self.selectedRow()
            column = self.selectedColumn()
            if not item == None:
                name = item.data()
                self.sbar.showMessage(str(name))
                
                #For Testing:
                global TestVariable
                TestVariable = item.data()

            print(name)
Snippet from CheckoutPopup.py:
    def currentValue(self):
     
      #Show the current value of the SpinBox in real time
      from AdminMenu import TestVariable
      self.messageText.setText("You are taking: "+str(self.CheckoutSpinBox.value()) + " " + TestVariable)
Error:
Error:
from AdminMenu import TestVariable ImportError: cannot import name 'TestVariable' from 'AdminMenu'
---------------------------------------------
Update:
---------------------------------------------
So I tried bringing the CheckoutSpinBox.value() to my AdminMenu.py but I get 0 every time. It's a step further but I need the value that the user entered once the Confirm Button is clicked (ConfirmClicked) not the default value of the spinbox (0). Is there a way to get that value the way I'm currently trying to do it?

Here's what I did in my AdminMenu.py
#----------------------------------
    #Checkout Function
    def CheckoutClicked(self):
        #Print in terminal for testing:
        print("The Checkout Button was clicked")

        from CheckoutPopup import Ui_CheckoutPopup
        x = Ui_CheckoutPopup()
        x.ConfirmClicked()
        print(x.CheckoutSpinBox.value())

        self.win = Ui_CheckoutPopup()
        self.win.show()
        #self.close()

#----------------------------------
Reply


Messages In This Thread
RE: Add a SpinBox to MsgBox or Carry Variable Over? - by Extra - Jun-05-2022, 01:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Validating and modifying a Spinbox pfdjhfuys 2 1,336 May-21-2023, 12:17 PM
Last Post: pfdjhfuys
  [PyQt] [Solved]How to Run GUI MsgBox From Terminal Properly Extra 4 1,793 Oct-03-2022, 11:01 PM
Last Post: Extra
  [PyQt] [Solved]Help getting variable from Function in PyQt Extra 6 1,574 Jul-06-2022, 10:19 PM
Last Post: Extra
  [Tkinter] how to celect com port from spinbox and make connect button 00alkskodi00 0 2,492 Apr-20-2020, 02:26 PM
Last Post: 00alkskodi00

Forum Jump:

User Panel Messages

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