我们从Python开源项目中,提取了以下42个代码示例,用于说明如何使用PySide.QtCore.QFile()。
def user_login_ui(self): loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.login_window_path) #file.open(QtCore.QFile.ReadOnly) self.loginWindow = loader.load(file, self) file.close() # set modal window self.loginWindow.setWindowModality(QtCore.Qt.WindowModal) self.loginWindow.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.loginWindow.show() # edit button self.loginWindow.login_button.clicked.connect(self.user_login_action) # finish print('login ui')
def new_workroom_ui(self): loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) self.newWorkroomDialog = loader.load(file, self) file.close() # edit widget self.newWorkroomDialog.setWindowTitle('add New WorkRoom') self.newWorkroomDialog.new_dialog_label.setText('Name:') # edit button self.newWorkroomDialog.new_dialog_cancel.clicked.connect(partial(self.new_workroom_action, False)) self.newWorkroomDialog.new_dialog_ok.clicked.connect(partial(self.new_workroom_action, True)) # set modal window self.newWorkroomDialog.setWindowModality(QtCore.Qt.WindowModal) self.newWorkroomDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.newWorkroomDialog.show() print('new workroom ui')
def new_project_ui(self): # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.qt_set_project_path) #file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle('Create Project') window.set_project_cansel_button.clicked.connect(partial(self.close_window, window)) window.set_project_ok_button.clicked.connect(partial(self.new_project_action, window)) window.set_project_path_button.clicked.connect(partial(self.get_share_dir, window.set_project_folder)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('new project ui')
def new_set_of_tasks_ui(self): # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_2_path) #file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget copy = self.db_studio window.setWindowTitle('Create Set Of Tasks') window.new_dialog_label.setText('Name of New Set:') window.new_dialog_label_2.setText('Type of Asset') window.new_dialog_combo_box.addItems(copy.asset_types) window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.new_set_of_tasks_action, window)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('create set of tasks')
def copy_set_of_tasks_ui(self): old_name = self.myWidget.studio_editor_table.currentItem().name # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Make Copy: ' + old_name)) window.new_dialog_label.setText('New Name of Set:') window.new_dialog_name.setText(old_name) window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.copy_set_of_tasks_action, window, old_name)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show()
def tm_change_tz_link_ui(self): # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeTzLinkWindow = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit window window.setWindowTitle(('Change Tz Link: \'' + self.current_task['task_name'] + '\"')) window.new_dialog_label.setText('Link:') window.new_dialog_name.setText(self.current_task['tz']) window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.tm_change_tz_link_action, window)) window.show()
def user_registration_ui(self): loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.user_registr_window_path) #file.open(QtCore.QFile.ReadOnly) self.myWidget.registrWindow = loader.load(file, self) file.close() # set modal window self.myWidget.registrWindow.setWindowModality(QtCore.Qt.WindowModal) self.myWidget.registrWindow.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.myWidget.registrWindow.show() # edit Button self.myWidget.registrWindow.user_registration_button.clicked.connect(self.user_registration_action) # finish print('registration ui')
def getSubsystemMapping(self): qfile = QtCore.QFile(":db/subsystemMap.csv") items = {} if qfile.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text): data = qfile.readAll() content = StringIO.StringIO(data) reader = csv.reader(content, delimiter=',') for row in reader: shipName = row[0].decode('utf-8') high = row[1].decode('utf-8') mid = row[2].decode('utf-8') low = row[3].decode('utf-8') items[shipName] = { "H": high, "M": mid, "L": low, } qfile.close() return items QMessageBox.critical(None, 'Database Failure', 'Failed to read subsystem mappings from database', QMessageBox.Ok) self.stop()
def save_file(self, fileName): '''(file open for writing)-> boolean ''' fname = QtCore.QFile(fileName) if not fname.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "Application", "Cannot write file %s:\n%s." % (fileName, fname.errorString())) return False outf = QtCore.QTextStream(fname) QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) outf << self.ui.textEdit.toPlainText() QtGui.QApplication.restoreOverrideCursor() # self.setCurrentFile(fileName); # QtGui.QMessageBox.about(self,'Information',"File saved")
def displaylog_totextedit(self): ''' This method displaying Design messages(log messages)to textedit widget. ''' afile = QtCore.QFile('./Connections/Shear/Finplate/fin.log') if not afile.open(QtCore.QIODevice.ReadOnly): # ReadOnly QtGui.QMessageBox.information(None, 'info', afile.errorString()) stream = QtCore.QTextStream(afile) self.ui.textEdit.clear() self.ui.textEdit.setHtml(stream.readAll()) vscrollBar = self.ui.textEdit.verticalScrollBar(); vscrollBar.setValue(vscrollBar.maximum()); afile.close()
def dict_from_csvqfile(file_path): reader = None qfile = QtCore.QFile(file_path) if qfile.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text): text = qfile.readAll() f = StringIO.StringIO(text) reader = csv.reader(f, delimiter=';') return reader
def getStyleSheet(): stream = QtCore.QFile(':/darkorange.qss') if stream.open(QtCore.QFile.ReadOnly): st = str(stream.readAll()) stream.close() else: print(stream.errorString()) return st
def __init__(self, MW): G.MW = MW task_data = MW.current_task nik_name = MW.current_user project = MW.current_project # make widjet ui_path = MW.chat_main_path # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(ui_path) #file.open(QtCore.QFile.ReadOnly) window = G.MW.chatMain = loader.load(file, MW) file.close() # fill meta data window.setWindowTitle('Lineyka Chat') window.chat_nik_name_label.setText(nik_name) window.chat_asset_name_label.setText(task_data['asset']) window.chat_task_name_label.setText(task_data['task_name'].split(':')[1]) # button connect window.close_button.clicked.connect(partial(MW.close_window, window)) window.reload_button.clicked.connect(partial(self.chat_load_topics, window)) window.chat_add_topic_button.clicked.connect(partial(self.chat_new_topic_ui, window)) window.show() self.chat_load_topics(window) print(MW.chat_status) # edit read_status if G.MW.chat_status == 'manager': result = G.MW.db_chat.task_edit_rid_status_read(project, task_data, nik_name) if not result[0]: G.MW.message(result[1], 2) return
def chat_image_view_ui(self, button): if not button.img_path: return # make widjet ui_path = G.MW.chat_img_viewer_path # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(ui_path) #file.open(QtCore.QFile.ReadOnly) img_window = G.MW.chatImgViewer = loader.load(file, G.MW) file.close() # SHOW IMAGE image = QtGui.QImage(button.img_path) img_window.setWindowTitle(button.img_path) img_window.image_label.setBackgroundRole(QtGui.QPalette.Base) img_window.image_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) img_window.image_label.setScaledContents(True) img_window.image_label.setPixmap(QtGui.QPixmap.fromImage(image)) # connect button img_window.cansel_button.clicked.connect(partial(G.MW.close_window, img_window)) img_window.show()
def push_comment_ui(self): # ask ask = self.message(('You save the file?'), 0) if not ask: return task_data = G.current_task # make widjet ui_path = self.new_dialog_path # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(ui_path) #file.open(QtCore.QFile.ReadOnly) window = self.lookVersionDialog = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit Widget window.setWindowTitle('Push Comment') window.new_dialog_label.setText('comment:') window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.push_action, window)) window.show() pass
def artist_edit_workroom_ui(self, current_widget): # select_from_list_dialog.ui loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.select_from_list_dialog_path) #file.open(QtCore.QFile.ReadOnly) self.selectWorkroomDialog = loader.load(file, self) file.close() # get exists workrooms workroom_list = [] if current_widget.workroom_field.text(): workroom_list = json.loads(current_widget.workroom_field.text()) # edit widget self.selectWorkroomDialog.setWindowTitle('Select WorkRoom') # edit table # -- fill table table = self.selectWorkroomDialog.select_from_list_data_list_table self.fill_workroom_table(table) # -- selection mode table.setSortingEnabled(True) table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) table.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) # edit button self.selectWorkroomDialog.select_from_list_cansel_button.clicked.connect(partial(self.close_window, self.selectWorkroomDialog)) self.selectWorkroomDialog.select_from_list_apply_button.clicked.connect(partial(self.artist_edit_workroom_action, current_widget)) # set modal window self.selectWorkroomDialog.setWindowModality(QtCore.Qt.WindowModal) self.selectWorkroomDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.selectWorkroomDialog.show()
def rename_workroom_ui(self): table = self.myWidget.studio_editor_table current_item = table.currentItem() if not current_item: self.message('Not Selected Workroom!', 2) return else: wr_data = current_item.workroom name = wr_data['name'] loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) self.newWorkroomDialog = loader.load(file, self) file.close() # edit widget self.newWorkroomDialog.setWindowTitle('Rename WorkRoom') self.newWorkroomDialog.new_dialog_label.setText('New Name:') self.newWorkroomDialog.new_dialog_name.setText(name) # edit button self.newWorkroomDialog.new_dialog_cancel.clicked.connect(partial(self.rename_workroom_action, False)) self.newWorkroomDialog.new_dialog_ok.clicked.connect(partial(self.rename_workroom_action, True)) # set modal window self.newWorkroomDialog.setWindowModality(QtCore.Qt.WindowModal) self.newWorkroomDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.newWorkroomDialog.show()
def rename_project_ui(self, table): column = table.columnCount() name_column = None for i in range(0, column): head_item = table.horizontalHeaderItem(i) if head_item.text() == 'name': name_column = i break # get selected rows selected = table.selectedItems() projects = [] for item in selected: if item.column() == name_column: projects.append(item.text()) if projects == []: self.message('Not Selected Project', 2) return project = projects[0] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Rename Project: ' + project)) window.new_dialog_label.setText('New Name:') window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.rename_project_action, window, project)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('new project ui', project)
def new_series_ui(self): # get project project = self.myWidget.set_comboBox_01.currentText() if project == '-- select project --': self.message('Not Project!', 3) return # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.createSeriesDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Create Series to \"' + project + '\"')) window.new_dialog_label.setText('Name of Series:') window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.new_series_action, window, project)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('new series ui')
def new_group_ui(self): # get project project = self.myWidget.set_comboBox_01.currentText() if project == '-- select project --': self.message('Not Project!', 3) return # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_4_path) #file.open(QtCore.QFile.ReadOnly) window = self.createGroupDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Create Group to \"' + project + '\"')) window.new_dialog_label.setText('Name of Group:') window.new_dialog_comment_label.setText('Comment:') window.new_dialog_label_2.setText('Type:') window.new_dialog_label_3.setText('Series:') window.new_dialog_frame_3.setVisible(False) window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.new_group_action, window, project)) # edit comobox #copy = db.studio() copy = self.db_studio types = ['-- select type --'] + copy.asset_types window.new_dialog_combo_box_2.addItems(types) window.new_dialog_combo_box_2.activated[str].connect(partial(self.new_group_ui_series_activation, window, project)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('new group ui')
def tm_edit_readers_ui(self): # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.select_from_list_dialog_3button_path) #file.open(QtCore.QFile.ReadOnly) window = self.editReadersDialog = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit Widget window.setWindowTitle('Edit Readers List') window.pushButton_01.setText('Remove Readers') window.pushButton_02.setText('Add Readers') # -- selection mode table = window.select_from_list_data_list_table table.setSortingEnabled(True) table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) table.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) # table_2 context menu table.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu ) addgrup_action = QtGui.QAction( 'make First', self.myWidget) addgrup_action.triggered.connect(partial(self.tm_make_first_reader, table)) table.addAction( addgrup_action ) # button connect window.select_from_list_cansel_button.clicked.connect(partial(self.close_window, window)) window.pushButton_01.clicked.connect(partial(self.tm_remove_reader_action)) window.pushButton_02.clicked.connect(self.tm_add_readers_ui) # load table self.tm_edit_readers_ui_reload_table() window.show()
def tm_add_readers_ui(self): # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.select_from_list_dialog_combobox_path) #file.open(QtCore.QFile.ReadOnly) window = self.selectReadersDialog = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit Widget table = window.select_from_list_data_list_table # -- labels window.setWindowTitle('Select Readers') window.select_from_list_apply_button.setText('Add') # -- selection mode table.setSortingEnabled(True) table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) table.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) # -- load workroom_list result = self.db_workroom.get_list_workrooms(DICTONARY = 'by_name') if not result[0]: self.message(result[1], 2) workroom_dict = result[1] window.workroom_dict = workroom_dict window.dialog_comboBox_1.addItems((['-select workroom-'] + workroom_dict.keys())) window.dialog_comboBox_1.activated[str].connect(partial(self.tm_add_readers_ui_load_artist_list)) # button connect window.select_from_list_cansel_button.clicked.connect(partial(self.close_window, window)) window.select_from_list_apply_button.clicked.connect(partial(self.tm_add_readers_action)) window.show()
def tm_change_task_activity_ui(self, *args): # get item item = self.myWidget.task_manager_table.currentItem() # get list of activity #copy = db.asset() activity_list = self.db_asset.activity_folder[self.current_group['type']].keys() activity_list.sort() # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeActivityWindow = loader.load(file, self) file.close() # edit window window.setWindowTitle(('Change Activity of Task: \'' + item.task['task_name'] + '\"')) window.combo_dialog_label.setText('Select Activity:') window.combo_dialog_combo_box.addItems(activity_list) window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.tm_change_task_activity_action, window, item)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show()
def tm_change_task_workroom_ui(self, *args): # get item item = self.myWidget.task_manager_table.currentItem() # get list of activity copy = self.db_workroom result = copy.get_list_workrooms(DICTONARY = 'by_name') if not result[0]: self.message(result[1], 2) return workroom_list = result[1].keys() workroom_list.sort() # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeActivityWindow = loader.load(file, self) file.close() # edit window window.setWindowTitle(('Change Workroom of Task: \'' + item.task['task_name'] + '\"')) window.combo_dialog_label.setText('Select WorkRoom:') window.combo_dialog_combo_box.addItems(workroom_list) window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.tm_change_task_workroom_action, window, item)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show()
def tm_change_task_input_ui(self, *args): # get item item = self.myWidget.task_manager_table.currentItem() # get task list task_list = [] result = self.db_chat.get_list(self.current_project, item.task['asset_id']) if result[0]: task_list = result[1] task_name_list = ['None'] for task in task_list: if task['task_name'].replace((task['asset'] + ':'),'') == 'final': continue elif task['task_name'] == item.task['task_name']: continue task_name_list.append(task['task_name']) print(task_name_list) # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeActivityWindow = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit window window.setWindowTitle(('Change Input Task: \'' + item.task['task_name'] + '\"')) window.combo_dialog_label.setText('Select Task:') window.combo_dialog_combo_box.addItems(task_name_list) window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.tm_change_task_input_action, window, item)) window.show()
def tm_change_task_type_ui(self): # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeActivityWindow = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit window content_list = self.db_studio.task_types content_list.sort() window.setWindowTitle(('Change Task Type: \'' + self.current_task['task_name'] + '\"')) window.combo_dialog_label.setText('Select Task Type:') window.combo_dialog_combo_box.addItems(content_list) try: window.combo_dialog_combo_box.setCurrentIndex(content_list.index(self.current_task['task_type'])) except: pass window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.tm_change_task_type_action, window)) window.show()
def tm_change_task_extension_ui(self): # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeActivityWindow = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit window content_list = self.db_studio.extensions content_list.sort() window.setWindowTitle(('Change Extension: \'' + self.current_task['task_name'] + '\"')) window.combo_dialog_label.setText('Select Extension:') window.combo_dialog_combo_box.addItems(content_list) try: window.combo_dialog_combo_box.setCurrentIndex(content_list.index(self.current_task['extension'])) except: pass window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.tm_change_task_extension_action, window)) window.show()
def getShipSlotMapping(self): qfile = QtCore.QFile(":db/shipMap.csv") items = {} if qfile.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text): data = qfile.readAll() content = StringIO.StringIO(data) reader = csv.reader(content, delimiter=',') for row in reader: shipName = row[0].decode('utf-8') high = row[1].decode('utf-8') mid = row[2].decode('utf-8') low = row[3].decode('utf-8') rig = row[4].decode('utf-8') sub = row[5].decode('utf-8') items[shipName] = { "H": high, "M": mid, "L": low, "R": rig, "S": sub } qfile.close() return items QMessageBox.critical(None, 'Database Failure', 'Failed to read ship mappings from database', QMessageBox.Ok) self.stop()
def getItemSlotMapping(self): qfile = QtCore.QFile(":db/slotMap.csv") items = {} if qfile.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text): data = qfile.readAll() content = StringIO.StringIO(data) reader = csv.reader(content, delimiter=',') for row in reader: items[row[0].decode('utf-8')] = row[1].decode('utf-8') return items QMessageBox.critical(None, 'Database Failure', 'Failed to read item mappings from database', QMessageBox.Ok) self.stop()
def save_inputs(self, uiObj): '''(Dictionary)--> None ''' inputFile = QtCore.QFile('saveINPUT.txt') if not inputFile.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "Application", "Cannot write file %s:\n%s." % (inputFile, file.errorString())) # yaml.dump(uiObj, inputFile,allow_unicode=True, default_flow_style = False) pickle.dump(uiObj, inputFile)
def chat_new_topic_ui(self, window): # make widjet ui_path = G.MW.chat_add_topic_path # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(ui_path) #file.open(QtCore.QFile.ReadOnly) add_window = G.MW.chatAddTopic = loader.load(file, G.MW) file.close() # set modal window add_window.setWindowModality(QtCore.Qt.WindowModal) add_window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # ****** add first line # H h_layout = QtGui.QHBoxLayout() line_frame = QtGui.QFrame(parent = add_window.new_topics_frame) # button button = QtGui.QPushButton('img', parent = line_frame) button.setFixedSize(100, 100) button.img_path = False h_layout.addWidget(button) # -- button connect button.clicked.connect(partial(self.chat_image_view_ui, button)) button.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu ) addgrup_action = QtGui.QAction( 'Inser Image From Clipboard', add_window) addgrup_action.triggered.connect(partial(self.chat_add_img_to_line, button)) button.addAction( addgrup_action ) # text field text_field = QtGui.QTextEdit(parent = line_frame) #text_field = QtGui.QTextBrowser(parent = line_frame) text_field.setMaximumHeight(100) h_layout.addWidget(text_field) line_frame.setLayout(h_layout) # V v_layout = QtGui.QVBoxLayout() v_layout.addWidget(line_frame) add_window.new_topics_frame.setLayout(v_layout) # ****** append line data add_window.line_data = {} add_window.line_data['1'] = (button, text_field) # connect button add_window.cansel_button.clicked.connect(partial(G.MW.close_window, add_window)) add_window.add_line_button.clicked.connect(partial(self.chat_add_line_to_message, add_window, v_layout)) add_window.send_message_button.clicked.connect(partial(self.chat_new_topic_action, add_window, G.MW.chat_status)) add_window.show()
def add_artist_ui(self): # get current level #copy = db.artist() current_artist = self.db_workroom.get_user() if not current_artist[0]: self.message(current_artist[1], 2) return current_nik_name = current_artist[1][0] ask = self.db_workroom.read_artist({'nik_name': current_nik_name}) current_level = ask[1][0]['level'] if current_level not in self.db_workroom.manager_levels: self.message('No Access!', 3) return # get levels levels = [] for level in self.db_workroom.user_levels: levels.append(level) if level == current_level: break # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.artist_dialog_path) #file.open(QtCore.QFile.ReadOnly) self.newArtistDialog = loader.load(file, self) file.close() # edit widget self.newArtistDialog.setWindowTitle('add New Artist') self.newArtistDialog.workroom_field.setEnabled(False) self.newArtistDialog.share_dir_field.setEnabled(False) self.newArtistDialog.level_combobox.addItems(levels) # workroom dialog self.newArtistDialog.artist_edit_workroom_button.clicked.connect(partial(self.artist_edit_workroom_ui, self.newArtistDialog)) # edit button self.newArtistDialog.get_share_dir_button.clicked.connect(partial(self.get_share_dir, self.newArtistDialog.share_dir_field)) self.newArtistDialog.artist_dialog_cancel.clicked.connect(partial(self.add_artist_action, False)) self.newArtistDialog.artist_dialog_ok.clicked.connect(partial(self.add_artist_action, True)) # set modal window self.newArtistDialog.setWindowModality(QtCore.Qt.WindowModal) self.newArtistDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.newArtistDialog.show()
def artist_edit_workroom2_ui(self, current_widget): # get all workrooms copy = self.db_workroom workrooms = copy.get_list_workrooms() if not workrooms[0]: self.message(workrooms[1], 3) return # get exists workrooms workroom_list = [] if current_widget.workroom_field.text(): workroom_list = json.loads(current_widget.workroom_field.text()) # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.select_from_check_button_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.selectWorkroomDialog2 = loader.load(file, self) file.close() # edit widget window.setWindowTitle('Select WorkRoom') # -- add checkbox checkbox_list = [] layout = QtGui.QVBoxLayout() for wr in workrooms[1]: wr_name = wr['name'] box = QtGui.QCheckBox(wr_name, window.check_buttons_frame) checkbox_list.append(box) if wr_name in workroom_list: box.setCheckState(QtCore.Qt.CheckState.Checked) layout.addWidget(box) window.check_buttons_frame.setLayout(layout) # -- edit button window.select_from_chbut_cansel_button.clicked.connect(partial(self.close_window, window)) window.select_from_chbut_apply_button.clicked.connect(partial(self.artist_edit_workroom2_action, current_widget, window, checkbox_list)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show()
def rename_set_of_tasks_ui(self, table): column = table.columnCount() name_column = None for i in range(0, column): head_item = table.horizontalHeaderItem(i) if head_item.text() == 'name': name_column = i break # get selected rows selected = table.selectedItems() lists = [] for item in selected: if item.column() == name_column: lists.append(item.text()) if lists == []: self.message('Not Selected Set', 2) return name = lists[0] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Rename: ' + name)) window.new_dialog_label.setText('New Name of Set:') window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.rename_set_of_tasks_action, name, window)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('rename set of tasks ui')
def edit_asset_type_ui(self, table): column = table.columnCount() name_column = None for i in range(0, column): head_item = table.horizontalHeaderItem(i) if head_item.text() == 'name': name_column = i break # get selected rows selected = table.selectedItems() lists = [] for item in selected: if item.column() == name_column: lists.append(item.text()) if lists == []: self.message('Not Selected Set', 2) return name = lists[0] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget #copy = db.studio() copy = self.db_studio window.setWindowTitle(('Edit Asset Type: ' + name)) window.combo_dialog_label.setText('New Name of Set:') window.combo_dialog_combo_box.addItems(copy.asset_types) window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.edit_asset_type_action, name, window)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('edit asset type')
def rename_series_ui(self, table): # get project project = self.myWidget.set_comboBox_01.currentText() if project == '-- select project --': self.message('Not Project!', 3) return # get old series column = table.columnCount() name_column = None for i in range(0, column): head_item = table.horizontalHeaderItem(i) if head_item.text() == 'name': name_column = i break # get selected rows selected = table.selectedItems() lists = [] for item in selected: if item.column() == name_column: lists.append(item.text()) if lists == []: self.message('Not Selected Series', 2) return name = lists[0] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.createSeriesDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Rename Series: \"' + name + '\"')) window.new_dialog_label.setText('New Name of Series:') window.new_dialog_name.setText(name) window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.rename_series_action, window, name)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('rename series ui')
def rename_group_ui(self, table): # get project project = self.myWidget.set_comboBox_01.currentText() if project == '-- select project --': self.message('Not Project!', 3) return # get old series column = table.columnCount() name_column = None for i in range(0, column): head_item = table.horizontalHeaderItem(i) if head_item.text() == 'name': name_column = i break # -- get selected rows selected = table.selectedItems() lists = [] for item in selected: if item.column() == name_column: lists.append(item.text()) if lists == []: self.message('Not Selected Series', 2) return # -- get name name = lists[0] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.new_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.createSeriesDialog = loader.load(file, self) file.close() # edit widget window.setWindowTitle(('Rename Group: \"' + name + '\"')) window.new_dialog_label.setText('New Name of Group:') window.new_dialog_name.setText(name) window.new_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.new_dialog_ok.clicked.connect(partial(self.rename_group_action, window, name, project)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('rename group ui')
def change_asset_group_ui(self, table): column = table.columnCount() name_column = None for i in range(0, column): head_item = table.horizontalHeaderItem(i) if head_item.text() == 'name': name_column = i break ''' # get selected rows selected = table.selectedItems() lists = [] for item in selected: if item.column() == name_column: lists.append(item.text()) if lists == []: self.message('Not Selected Group', 2) return asset_name = lists[0] ''' # get asset data asset_data = table.currentItem().asset asset_name = asset_data['name'] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.setProjectDialog = loader.load(file, self) file.close() # edit widget #copy = db.group() group_list = ['-- new groups --'] #result = copy.get_by_type_list(self.current_project, [self.current_group['type']]) #result = copy.get_by_type_list(self.current_project, [asset_data['type']]) result = self.db_group.get_by_type_list(self.current_project, [asset_data['type']]) if result[0]: for row in result[1]: if row['name'] != self.current_group['name']: group_list.append(row['name']) window.groups = result[1] else: print(result[1]) window.setWindowTitle(('Change Group Asset: \"' + asset_name + '\"')) window.combo_dialog_label.setText('Select New Group:') window.combo_dialog_combo_box.addItems(group_list) window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.change_asset_group_action, asset_data, window)) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show() print('change asset group')
def tm_change_task_artist_ui(self, *args): # get item item = self.myWidget.task_manager_table.currentItem() # task workroom task_workroom = item.task['workroom'] # get list of active artists result = self.db_workroom.read_artist({'status':'active'}) if not result[0]: self.message(result[1], 2) return active_artists_list = [] for row in result[1]: if row['workroom']: artist_workrooms = json.loads(row['workroom']) if task_workroom in artist_workrooms: active_artists_list.append(row['nik_name']) else: continue active_artists_list.sort() active_artists_list.insert(0, '-None-') # create window loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.combo_dialog_path) #file.open(QtCore.QFile.ReadOnly) window = self.changeActivityWindow = loader.load(file, self) file.close() # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # edit window window.setWindowTitle(('Change Artist of Task: \'' + item.task['task_name'] + '\"')) window.combo_dialog_label.setText('Select Artist:') window.combo_dialog_combo_box.addItems(active_artists_list) window.combo_dialog_cancel.clicked.connect(partial(self.close_window, window)) window.combo_dialog_ok.clicked.connect(partial(self.tm_change_task_artist_action, window, item)) window.show()