I’m a beginner and starting with PySide6 and Qt designer for creating a GUI.
I already done with making GUI from Qt Designer. I already done making the interface with sidebar,header and stacked widget.
Programmatically the button seems working from interface.py,
I tried making a different file to work for each stacked widget,
when i connect a button from different file, it didnt work at all.
The Stacked Widget is inside the ui_interface.py
My code interface.py connect some button in the interface (sidebar and menu).
this code work as i intended.
from ui_interface import Ui_MainWindow
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QMenu
from PySide6.QtGui import QAction
class MyInterface (QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.setWindowTitle("Study")
#Connect Button into Page
self.name_sidebar_dashboard_button.clicked.connect(self.switch_to_main_screen_dashboard_page)
self.icon_sidebar_dashboard_button.clicked.connect(self.switch_to_main_screen_dashboard_page)
self.name_sidebar_sugar_button.clicked.connect(self.switch_to_main_screen_dashboard_page)
self.icon_sidebar_sugar_button.clicked.connect(self.switch_to_main_screen_dashboard_page)
etc.....
#Switch Page
def switch_to_main_screen_dashboard_page(self):
self.main_screen_stackedWidget.setCurrentIndex(0)
def switch_to_main_screen_lineParamex_sugar_page(self):
self.main_screen_stackedWidget.setCurrentIndex(1)
etc.....
then i tried to make sugar.py to make things work in sugar page. I tried to make a button in this sugar page to import an .ods file.
The code for interface.py running smoothly, but the code in sugar.py didn’t work at all.
I’m stuck,
import pandas as pd
import sys
import os
from interface import MyInterface
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QFileDialog, QWidget
class Konidin (QWidget):
def __init__(self, MyInterface):
self.main_screen_lineTablet_konidin_import_button.clicked.connect(self.import_konidin)
def import_konidin(self):
path = QFileDialog.getOpenFileName(self, 'Open ODS', os.getenv('HOME'), 'ODS(*.ods)')[0]
self.all_data = pd.read_excel(path,engine="odf")
Harum Sukma Aji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.