def show_tension_module(self): # folder = self.select_workspace_folder() # folder = str(folder) # if not os.path.exists(folder): # if folder == '': # pass # else: # os.mkdir(folder, 0o755) # # root_path = folder # images_html_folder = ['images_html'] # flag = True # for create_folder in images_html_folder: # if root_path == '': # flag = False # return flag # else: # try: # os.mkdir(os.path.join(root_path, create_folder)) # except OSError: # shutil.rmtree(os.path.join(folder, create_folder)) # os.mkdir(os.path.join(root_path, create_folder)) if self.findChild(QRadioButton,'Tension_Bolted').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(Tension_bolted, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Tension_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(Tension_welded, ' ') self.ui2.show() self.ui2.closed.connect(self.show)
def show_shear_connection(self): if self.findChild(QRadioButton,'Fin_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(FinPlateConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Cleat_Angle').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(CleatAngleConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Seated_Angle').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow( SeatedAngleConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'End_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(EndPlateConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) else: QMessageBox.about(self, "INFO", "Please select appropriate connection")
def show_moment_connection_cc(self): if self.findChild(QRadioButton,'C2C_Cover_Plate_Bolted').isChecked() : self.hide() self.ui2 = Ui_ModuleWindow(ColumnCoverPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'C2C_Cover_Plate_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(ColumnCoverPlateWeld, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'C2C_End_Plate_Connection').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(ColumnEndPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show)
def show_moment_connection(self): if self.findChild(QRadioButton,'B2B_Cover_Plate_Bolted').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamCoverPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'B2B_Cover_Plate_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamCoverPlateWeld, ' ') self.ui2.show() self.ui2.closed.connect(self.show) # elif self.findChild(QRadioButton,'B2B_End_Plate_Connection').isChecked(): # self.hide() # self.ui2 = Ui_ModuleWindow(BeamBeamEndPlateSplice,' ') # self.ui2.show() # self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton, 'B2B_End_Plate_Splice').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamBeamEndPlateSplice, ' ') self.ui2.show() self.ui2.closed.connect(self.show)
def show_base_plate(self): if self.findChild(QRadioButton, 'Base_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BasePlateConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show)
def show_moment_connection_bc(self): if self.findChild(QRadioButton,'BC_End_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamColumnEndPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show)
class OsdagMainWindow(QMainWindow): def __init__(self): super().__init__() resolution = QtWidgets.QDesktopWidget().screenGeometry() width = resolution.width() height = resolution.height() self.ui=Ui_MainWindow() self.ui.setupUi(self) self.ui.switch.toggled.connect(self.change_theme) self.ui.comboBox_help.currentIndexChanged.connect(self.selection_change) self.ui.myStackedWidget.currentChanged.connect(self.current_changed) self.Under_Development='UNDER DEVELOPMENT' self.Modules={ 'Connection' : { 'Shear Connection' : [ ('Fin Plate','ResourceFiles/images/finplate.png','Fin_Plate'), ('Cleat Angle','ResourceFiles/images/cleatAngle.png','Cleat_Angle'), ('End Plate','ResourceFiles/images/endplate.png','End_Plate'), ('Seated Angle','ResourceFiles/images/seatedAngle1.png','Seated_Angle'), self.show_shear_connection, ], 'Moment Connection' :{ 'Beam-to-Beam Splice' :[ ('Cover Plate Bolted','ResourceFiles/images/bbcoverplatebolted.png','B2B_Cover_Plate_Bolted'), ('Cover Plate Welded','ResourceFiles/images/bbcoverplatewelded.png','B2B_Cover_Plate_Welded'), ('End Plate', 'ResourceFiles/images/bb_splice.png', 'B2B_End_Plate_Splice'), self.show_moment_connection, ], 'Beam-to-Column': [ ('End Plate', 'ResourceFiles/images/BC-EBW_GUI.png','BC_End_Plate'), self.show_moment_connection_bc ], 'Column-to-Column Splice' :[ ('Cover Plate Bolted','ResourceFiles/images/cccoverplatebolted.png','C2C_Cover_Plate_Bolted'), ('Cover Plate Welded','ResourceFiles/images/cccoverplatewelded.png','C2C_Cover_Plate_Welded'), ('End Plate','ResourceFiles/images/ccep_flush.png','C2C_End_Plate_Connection'), self.show_moment_connection_cc, ], 'PEB' : self.Under_Development, }, 'Base Plate':[ ('Base Plate Connection', 'ResourceFiles/images/base_plate.png', 'Base_Plate'), self.show_base_plate, ], 'Truss Connection' : self.Under_Development, }, 'Tension Member' : [ ('Bolted to End Gusset','ResourceFiles/images/bolted_ten.png','Tension_Bolted'), ('Welded to End Gusset','ResourceFiles/images/welded_ten.png','Tension_Welded'), self.show_tension_module, ], 'Compression Member' : self.Under_Development, 'Flexural Member' : self.Under_Development, 'Beam-Column' : self.Under_Development, 'Plate Girder' : self.Under_Development, 'Truss' : self.Under_Development, '2D Frame' : self.Under_Development, '3D Frame' : self.Under_Development, 'Group Design' : self.Under_Development, } ####################################### UI Formation ################################ for ModuleName in self.Modules: #Level 1 dictionary handling Button= LeftPanelButton(ModuleName) self.ButtonConnection(Button,list(self.Modules.keys()),ModuleName) self.ui.verticalLayout.addWidget(Button) if(type(self.Modules[ModuleName])==dict): #level 2 dictionary handling Page= ModulePage() self.ui.myStackedWidget.addWidget(Page) Current_Module=self.Modules[ModuleName] Tab_Widget=New_Tab_Widget() Page.layout.addWidget(Tab_Widget) for Submodule in Current_Module: if(type(Current_Module[Submodule])==dict): #Level 3 dictionary handling New_Tab=ModulePage() Tab_Widget.addTab(New_Tab,Submodule) Sub_Page= ModulePage() New_Tab.layout.addWidget(Sub_Page) Current_SubModule=Current_Module[Submodule] Sub_Tab_Widget=New_Tab_Widget() Sub_Page.layout.addWidget(Sub_Tab_Widget) for Sub_Sub_Module in Current_SubModule: if(type(Current_SubModule[Sub_Sub_Module]) in [list,tuple]): # Final List/tuple Handling New_Sub_Tab=Submodule_Page() Sub_Tab_Widget.addTab(New_Sub_Tab,Sub_Sub_Module) group=QButtonGroup(QWidget(Page)) row,col=0,0 n=math.floor((len(Current_SubModule[Sub_Sub_Module])-2)/2) for Selection in Current_SubModule[Sub_Sub_Module][:-1]: widget=Submodule_Widget(Selection,New_Sub_Tab) group.addButton(widget.rdbtn) New_Sub_Tab.ui.gridLayout.addWidget(widget,row,col) if(col==n and len(Current_SubModule[Sub_Sub_Module])!=3): row+=1 col=0 else: col+=1 New_Sub_Tab.ui.StartButton.clicked.connect(Current_SubModule[Sub_Sub_Module][-1]) elif(Current_SubModule[Sub_Sub_Module]==self.Under_Development): # Final Under Development Handling Sub_Tab_Widget.addTab(self.UnderDevelopmentModule(),Sub_Sub_Module) else: raise ValueError elif(type(Current_Module[Submodule]) in [list,tuple]): #Level 3 list/tuple handling New_Tab=Submodule_Page() Tab_Widget.addTab(New_Tab,Submodule) group=QButtonGroup(QWidget(Page)) row,col=0,0 n=math.floor((len(Current_Module[Submodule])-2)/2) for Selection in Current_Module[Submodule][:-1]: widget=Submodule_Widget(Selection,New_Tab) group.addButton(widget.rdbtn) New_Tab.ui.gridLayout.addWidget(widget,row,col) if(col==n and len(Current_Module[Submodule])!=3): row+=1 col=0 else: col+=1 New_Tab.ui.StartButton.clicked.connect(Current_Module[Submodule][-1]) elif(Current_Module[Submodule]==self.Under_Development): #Level 3 Under Development handling Tab_Widget.addTab(self.UnderDevelopmentModule(),Submodule) else: raise ValueError elif(type(self.Modules[ModuleName]) in [list,tuple]): # Level 2 list/tuple handling Page= Submodule_Page() self.ui.myStackedWidget.addWidget(Page) group=QButtonGroup(QWidget(Page)) row,col=0,0 n=math.floor((len(self.Modules[ModuleName])-2)/2) for Selection in self.Modules[ModuleName][:-1]: widget=Submodule_Widget(Selection,Page) group.addButton(widget.rdbtn) Page.ui.gridLayout.addWidget(widget,row,col) if(col==n and len(self.Modules[ModuleName])!=3): row+=1 col=0 else: col+=1 Page.ui.StartButton.clicked.connect(self.Modules[ModuleName][-1]) elif(self.Modules[ModuleName]==self.Under_Development): #Level 2 Under Development handling self.ui.myStackedWidget.addWidget(self.UnderDevelopmentModule()) else: raise ValueError self.resize(width * (0.85), height * (0.75)) self.center() self.show() def center(self): frameGm = self.frameGeometry() screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos()) centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) @pyqtSlot(int) def current_changed(self, index): l = list(self.Modules.keys()) items = list(self.ui.verticalLayout.itemAt(i) for i in range(self.ui.verticalLayout.count())) # print(items,"hfhh") for item in range(len(items)): if item == index-1: items[item].widget().ui.LP_Button.setStyleSheet(''' background-color: qradialgradient(cx: 0.5, cy: 0.5, radius: 2, fx: 0.5, fy: 1, stop: 0 rgba(130, 36, 38,190), stop: 0.2 rgb(171, 39, 42), stop: 0.4 rgba(255,30,30,32)); ''') else: items[item].widget().ui.LP_Button.setStyleSheet(";") ################################ UI Methods ############################################### def closeEvent(self, event): try: sqlitepath = Path('ResourceFiles/Database/Intg_osdag.sqlite') sqlpath = Path('ResourceFiles/Database/Intg_osdag.sql') precisionscript = 'ResourceFiles/Database/precision.awk' if sqlitepath.exists() and ( not sqlpath.exists() or sqlpath.stat().st_size == 0 or sqlpath.stat().st_mtime < sqlitepath.stat().st_mtime - 1): sqlnewpath = Path('ResourceFiles/Database/Intg_osdag_new.sql') cmd = 'sqlite3 ' + str(sqlitepath) + ' .dump | gawk -f ' + precisionscript + ' > ' + str(sqlnewpath) error = os.system(cmd) # if error != 0: # raise Exception('SQLite conversion to SQL error 1') # if sqlnewpath.stat().st_size == 0: # raise Exception('SQLite conversion to SQL error 2') os.remove(sqlpath) sqlnewpath.rename(sqlpath) sqlitepath.touch() print('DUMP updated') except Exception as e: sqlnewpath.unlink() print('Error: ', e) def selection_change(self): loc = self.ui.comboBox_help.currentText() if loc == "Design Examples": self.design_examples() elif loc == "Video Tutorials": self.open_tutorials() elif loc == "About Osdag": self.about_osdag() elif loc == "Ask Us a Question": self.ask_question() elif loc == "Check for Update": update_class = Update() msg = update_class.notifi() QMessageBox.information(self, 'Info',msg) # elif loc == "FAQ": # pass def select_workspace_folder(self): # This function prompts the user to select the workspace folder and returns the name of the workspace folder config = configparser.ConfigParser() config.read_file(open(r'Osdag.config')) desktop_path = config.get("desktop_path", "path1") folder = QFileDialog.getExistingDirectory(self, "Select Workspace Folder (Don't use spaces in the folder name)", desktop_path) return folder @staticmethod def UnderDevelopmentModule(): Page= ModulePage() label=QLabel('This Module is Currently Under Development') Page.layout.addWidget(label) label.setAlignment(Qt.AlignCenter) label.setObjectName('under_development_label') return Page def ButtonConnection(self,Button,Modules,ModuleName): Button.ui.LP_Button.clicked.connect(lambda : self.ui.myStackedWidget.setCurrentIndex(Modules.index(ModuleName)+1)) #################################### Module Launchers ########################################## @pyqtSlot() def show_shear_connection(self): if self.findChild(QRadioButton,'Fin_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(FinPlateConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Cleat_Angle').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(CleatAngleConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Seated_Angle').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow( SeatedAngleConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'End_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(EndPlateConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) else: QMessageBox.about(self, "INFO", "Please select appropriate connection") def show_moment_connection(self): if self.findChild(QRadioButton,'B2B_Cover_Plate_Bolted').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamCoverPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'B2B_Cover_Plate_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamCoverPlateWeld, ' ') self.ui2.show() self.ui2.closed.connect(self.show) # elif self.findChild(QRadioButton,'B2B_End_Plate_Connection').isChecked(): # self.hide() # self.ui2 = Ui_ModuleWindow(BeamBeamEndPlateSplice,' ') # self.ui2.show() # self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton, 'B2B_End_Plate_Splice').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamBeamEndPlateSplice, ' ') self.ui2.show() self.ui2.closed.connect(self.show) def show_moment_connection_bc(self): if self.findChild(QRadioButton,'BC_End_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BeamColumnEndPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show) def show_base_plate(self): if self.findChild(QRadioButton, 'Base_Plate').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(BasePlateConnection, ' ') self.ui2.show() self.ui2.closed.connect(self.show) def show_moment_connection_cc(self): if self.findChild(QRadioButton,'C2C_Cover_Plate_Bolted').isChecked() : self.hide() self.ui2 = Ui_ModuleWindow(ColumnCoverPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'C2C_Cover_Plate_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(ColumnCoverPlateWeld, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'C2C_End_Plate_Connection').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(ColumnEndPlate, ' ') self.ui2.show() self.ui2.closed.connect(self.show) def show_compression_module(self): # folder = self.select_workspace_folder() # folder = str(folder) # if not os.path.exists(folder): # if folder == '': # pass # else: # os.mkdir(folder, 0o755) # # root_path = folder # images_html_folder = ['images_html'] # flag = True # for create_folder in images_html_folder: # if root_path == '': # flag = False # return flag # else: # try: # os.mkdir(os.path.join(root_path, create_folder)) # except OSError: # shutil.rmtree(os.path.join(folder, create_folder)) # os.mkdir(os.path.join(root_path, create_folder)) if self.findChild(QRadioButton,'Compression_Bolted').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(Compression, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Compression_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(Compression, ' ') self.ui2.show() self.ui2.closed.connect(self.show) def show_tension_module(self): # folder = self.select_workspace_folder() # folder = str(folder) # if not os.path.exists(folder): # if folder == '': # pass # else: # os.mkdir(folder, 0o755) # # root_path = folder # images_html_folder = ['images_html'] # flag = True # for create_folder in images_html_folder: # if root_path == '': # flag = False # return flag # else: # try: # os.mkdir(os.path.join(root_path, create_folder)) # except OSError: # shutil.rmtree(os.path.join(folder, create_folder)) # os.mkdir(os.path.join(root_path, create_folder)) if self.findChild(QRadioButton,'Tension_Bolted').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(Tension_bolted, ' ') self.ui2.show() self.ui2.closed.connect(self.show) elif self.findChild(QRadioButton,'Tension_Welded').isChecked(): self.hide() self.ui2 = Ui_ModuleWindow(Tension_welded, ' ') self.ui2.show() self.ui2.closed.connect(self.show) ################################# Help Actions ############################################ def about_osdag(self): dialog = MyAboutOsdag(self) dialog.show() def open_osdag(self): self.about_osdag() def tutorials(self): dialog = MyTutorials(self) dialog.show() def open_tutorials(self): self.tutorials() def ask_question(self): dialog = MyAskQuestion(self) dialog.show() def open_question(self): self.ask_question() def design_examples(self): root_path = os.path.join('ResourceFiles', 'design_example', '_build', 'html') for html_file in os.listdir(root_path): # if html_file.startswith('index'): print(os.path.splitext(html_file)[1]) if os.path.splitext(html_file)[1] == '.html': if sys.platform == ("win32" or "win64"): os.startfile(os.path.join(root_path, html_file)) else: opener ="open" if sys.platform == "darwin" else "xdg-open" subprocess.call([opener, "%s/%s" % (root_path, html_file)]) def change_theme(self): state = self.ui.switch.isChecked() toggle_stylesheet(state)