def quickMenu(self, ui_names):
if isinstance(self, QtWidgets.QMainWindow):
menubar = self.menuBar()
for each_ui in ui_names:
createOpt = each_ui.split(';')
if len(createOpt) > 1:
uiName = createOpt[0]
uiLabel = createOpt[1]
self.uiList[uiName] = QtWidgets.QMenu(uiLabel)
menubar.addMenu(self.uiList[uiName])
else:
print("Warning (QuickMenu): Only QMainWindow can have menu bar.")
python类QMainWindow()的实例源码
universal_tool_template_v8.1.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 28
收藏 0
点赞 0
评论 0
universal_tool_template_1010.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def setupUI(self, layout='grid'):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout(layout, 'main_layout')
self.setLayout(main_layout)
universal_tool_template_1010.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 29
收藏 0
点赞 0
评论 0
def __init__(self, parent=None, mode=0):
UniversalToolUI.__init__(self, parent)
# class variables
self.version= version
self.date = date
self.log = log
self.help = help
# mode: example for receive extra user input as parameter
self.mode = 0
if mode in [0,1]:
self.mode = mode # mode validator
# Custom user variable
#------------------------------
# initial data
#------------------------------
self.memoData['data']=[]
self.qui_user_dict = {} # e.g: 'edit': 'LNTextEdit',
self.setupStyle()
if isinstance(self, QtWidgets.QMainWindow):
self.setupMenu()
self.setupWin()
self.setupUI()
self.Establish_Connections()
self.loadLang()
self.loadData()
#------------------------------
# overwrite functions
#------------------------------
def __init__(self, sandbox, *args, **kwargs):
QtGui.QMainWindow.__init__(self, *args, **kwargs)
loadUi(get_resource('window_reference.ui'), self)
self.move(
self.parent().window().mapToGlobal(
self.parent().window().rect().center()) -
self.mapToGlobal(self.rect().center()))
self.sandbox = sandbox
self.actionOptimizeSource.triggered.connect(
self.sandbox.optimizeSource)
self.createView(self.sandbox)
def getMainWindowByName(name):
toplevel2 = QtGui.qApp.topLevelWidgets()
for i in toplevel2:
if name == i.windowTitle():
i.show()
return i
r=QtGui.QMainWindow()
FreeCAD.r=r
r.setWindowTitle(name)
r.show()
return r
universal_tool_template_1020.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def __init__(self, parent=None, mode=0):
QtWidgets.QMainWindow.__init__(self, parent)
#------------------------------
# class variables
#------------------------------
self.version = '0.1'
self.date = '2017.01.01'
self.log = 'no version log in user class'
self.help = 'no help guide in user class'
self.uiList={} # for ui obj storage
self.memoData = {} # key based variable data storage
self.memoData['font_size_default'] = QtGui.QFont().pointSize()
self.memoData['font_size'] = self.memoData['font_size_default']
self.memoData['last_export'] = ''
self.memoData['last_import'] = ''
self.name = self.__class__.__name__
self.location = ''
if getattr(sys, 'frozen', False):
# frozen - cx_freeze
self.location = sys.executable
else:
# unfrozen
self.location = os.path.realpath(sys.modules[self.__class__.__module__].__file__)
self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png')
self.iconPix = QtGui.QPixmap(self.iconPath)
self.icon = QtGui.QIcon(self.iconPath)
self.fileType='.{0}_EXT'.format(self.name)
#------------------------------
# core function variable
#------------------------------
self.qui_core_dict = {
'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
'txt': 'QTextEdit',
'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget',
'space': 'QSpacerItem',
'menu' : 'QMenu', 'menubar' : 'QMenuBar',
}
self.qui_user_dict = {}
def setupWin(self):
self.setWindowTitle("UITranslator" + " - v" + self.version + " - host: " + hostMode)
self.setGeometry(300, 300, 300, 300)
#------------------------------
# auto window icon setup
path = os.path.join(os.path.dirname(self.location),'icons','UITranslator.png')
self.setWindowIcon(QtGui.QIcon(path))
#------------------------------
# initial win drag position
self.drag_position=QtGui.QCursor.pos()
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
#############################################
# customized SUPER quick ui function for speed up programming
#############################################
universal_tool_template_v7.3.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def setupUI(self):
#==============================
# main_layout for QMainWindow
main_widget = QtGui.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
'''
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
'''
#------------------------------
# ui element creation part
# quickUI version from universal tool template v6
'''
upper_layout = self.quickUI(["source_txtEdit;LNTextEdit","process_btn;QPushButton;Process and Update"],"upper_QVBoxLayout")
upper_layout.setContentsMargins(0,0,0,0)
input_split = self.quickSplitUI("input_split", [ upper_layout, self.quickUI(["result_txtEdit;LNTextEdit"])[0] ], "v")
fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout")
self.quickUI([input_split, fileBtn_layout], main_layout)
self.uiList["source_txtEdit"].setWrap(0)
self.uiList["result_txtEdit"].setWrap(0)
'''
#------------------------------
# qui version from template 7
# no extra variable name, all text based creation and reference
self.qui('source_txtEdit | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txtEdit', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('input_split | fileBtn_layout', 'main_layout')
self.uiList["source_txtEdit"].setWrap(0)
self.uiList["result_txtEdit"].setWrap(0)
'''
self.uiList['secret_btn'] = QtGui.QPushButton(self) # invisible but functional button
self.uiList['secret_btn'].setText("")
self.uiList['secret_btn'].setGeometry(0, 0, 50, 20)
self.uiList['secret_btn'].setStyleSheet("QPushButton{background-color: rgba(0, 0, 0,0);} QPushButton:pressed{background-color: rgba(0, 0, 0,0); border: 0px;} QPushButton:hover{background-color: rgba(0, 0, 0,0); border: 0px;}")
#:hover:pressed:focus:hover:disabled
'''
#------------- end ui creation --------------------
for name,each in self.uiList.items():
if isinstance(each, QtGui.QLayout) and name!='main_layout' and not name.endswith('_grp_layout'):
each.setContentsMargins(0,0,0,0)
self.quickInfo('Ready')
universal_tool_template_0904.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def loadLang(self):
if isinstance(self, QtWidgets.QMainWindow):
self.quickMenu(['language_menu;&Language'])
cur_menu = self.uiList['language_menu']
self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
cur_menu.addSeparator()
self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default'))
# store default language
self.memoData['lang']={}
self.memoData['lang']['default']={}
for ui_name in self.uiList:
ui_element = self.uiList[ui_name]
if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
# uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
self.memoData['lang']['default'][ui_name] = str(ui_element.text())
elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
# uiType: QMenu, QGroupBox
self.memoData['lang']['default'][ui_name] = str(ui_element.title())
elif type(ui_element) in [ QtWidgets.QTabWidget]:
# uiType: QTabWidget
tabCnt = ui_element.count()
tabNameList = []
for i in range(tabCnt):
tabNameList.append(str(ui_element.tabText(i)))
self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
elif type(ui_element) == str:
# uiType: string for msg
self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]
# try load other language
lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
baseName = os.path.splitext( os.path.basename(self.location) )[0]
for fileName in os.listdir(lang_path):
if fileName.startswith(baseName+"_lang_"):
langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
self.memoData['lang'][ langName ] = self.readFileData( os.path.join(lang_path,fileName) )
if isinstance(self, QtWidgets.QMainWindow):
self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', self.uiList['language_menu'])
self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName))
# if no language file detected, add export default language option
if isinstance(self, QtWidgets.QMainWindow) and len(self.memoData['lang']) == 1:
self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', self.uiList['language_menu'])
self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
universal_tool_template_0803.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('source_txt | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txt', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('input_split | fileBtn_layout', 'main_layout')
# - template : quickUI version since universal tool template v6
'''
upper_layout = self.quickUI(["source_txt;QTextEdit","process_btn;QPushButton;Process and Update"],"upper_QVBoxLayout")
upper_layout.setContentsMargins(0,0,0,0)
input_split = self.quickSplitUI("input_split", [ upper_layout, self.quickUI(["result_txt;QTextEdit"])[0] ], "v")
fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout")
self.quickUI([input_split, fileBtn_layout], main_layout)
'''
# - template : invisible but functional button
'''
self.uiList['secret_btn'] = QtWidgets.QPushButton(self)
self.uiList['secret_btn'].setText("")
self.uiList['secret_btn'].setGeometry(0, 0, 50, 20)
self.uiList['secret_btn'].setStyleSheet("QPushButton{background-color: rgba(0, 0, 0,0);} QPushButton:pressed{background-color: rgba(0, 0, 0,0); border: 0px;} QPushButton:hover{background-color: rgba(0, 0, 0,0); border: 0px;}")
#:hover:pressed:focus:hover:disabled
'''
#------------- end ui creation --------------------
keep_margin_layout = ['main_layout']
for name, each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name not in keep_margin_layout and not name.endswith('_grp_layout'):
each.setContentsMargins(0, 0, 0, 0)
self.quickInfo('Ready')
universal_tool_template_0903.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def loadLang(self):
if isinstance(self, QtWidgets.QMainWindow):
self.quickMenu(['language_menu;&Language'])
cur_menu = self.uiList['language_menu']
self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
cur_menu.addSeparator()
self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default'))
# store default language
self.memoData['lang']={}
self.memoData['lang']['default']={}
for ui_name in self.uiList:
ui_element = self.uiList[ui_name]
if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
# uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
self.memoData['lang']['default'][ui_name] = str(ui_element.text())
elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
# uiType: QMenu, QGroupBox
self.memoData['lang']['default'][ui_name] = str(ui_element.title())
elif type(ui_element) in [ QtWidgets.QTabWidget]:
# uiType: QTabWidget
tabCnt = ui_element.count()
tabNameList = []
for i in range(tabCnt):
tabNameList.append(str(ui_element.tabText(i)))
self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
elif type(ui_element) == str:
# uiType: string for msg
self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]
# try load other language
lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
baseName = os.path.splitext( os.path.basename(self.location) )[0]
for fileName in os.listdir(lang_path):
if fileName.startswith(baseName+"_lang_"):
langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
self.memoData['lang'][ langName ] = self.readFileData( os.path.join(lang_path,fileName) )
if isinstance(self, QtWidgets.QMainWindow):
self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', self.uiList['language_menu'])
self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName))
# if no language file detected, add export default language option
if isinstance(self, QtWidgets.QMainWindow) and len(self.memoData['lang']) == 1:
self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', self.uiList['language_menu'])
self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
universal_tool_template_v8.1.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def setupWin(self):
self.setWindowTitle("UniversalToolUI" + " - v" + self.version + " - host: " + hostMode)
self.setGeometry(500, 300, 250, 110) # self.resize(250,250)
#------------------------------
# auto window icon setup
path = os.path.join(os.path.dirname(self.location),'icons','UniversalToolUI.png')
self.setWindowIcon(QtGui.QIcon(path))
#------------------------------
# initial win drag position
self.drag_position=QtGui.QCursor.pos()
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
#############################################
# customized SUPER quick ui function for speed up programming
#############################################
universal_tool_template_v8.1.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 28
收藏 0
点赞 0
评论 0
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('source_txtEdit | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txtEdit', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('input_split | fileBtn_layout', 'main_layout')
self.uiList["source_txtEdit"].setWrap(0)
self.uiList["result_txtEdit"].setWrap(0)
# - template : quickUI version since universal tool template v6
'''
upper_layout = self.quickUI(["source_txtEdit;LNTextEdit","process_btn;QPushButton;Process and Update"],"upper_QVBoxLayout")
upper_layout.setContentsMargins(0,0,0,0)
input_split = self.quickSplitUI("input_split", [ upper_layout, self.quickUI(["result_txtEdit;LNTextEdit"])[0] ], "v")
fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout")
self.quickUI([input_split, fileBtn_layout], main_layout)
self.uiList["source_txtEdit"].setWrap(0)
self.uiList["result_txtEdit"].setWrap(0)
'''
# - template : invisible but functional button
'''
self.uiList['secret_btn'] = QtWidgets.QPushButton(self)
self.uiList['secret_btn'].setText("")
self.uiList['secret_btn'].setGeometry(0, 0, 50, 20)
self.uiList['secret_btn'].setStyleSheet("QPushButton{background-color: rgba(0, 0, 0,0);} QPushButton:pressed{background-color: rgba(0, 0, 0,0); border: 0px;} QPushButton:hover{background-color: rgba(0, 0, 0,0); border: 0px;}")
#:hover:pressed:focus:hover:disabled
'''
#------------- end ui creation --------------------
for name,each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name!='main_layout' and not name.endswith('_grp_layout'):
each.setContentsMargins(0,0,0,0) # clear extra margin some nested layout
#self.quickInfo('Ready')
def __init__(self, *args, **kwargs):
filename = kwargs.pop('filename', None)
QtGui.QMainWindow.__init__(self, *args, **kwargs)
loadUi(get_resource('talpa.ui'), baseinstance=self)
self.sandbox = SandboxModel.empty()
self.log = SceneLog(self, self.sandbox)
self.actionSaveModel.triggered.connect(
self.onSaveModel)
self.actionLoadModel.triggered.connect(
self.loadModel)
self.actionExportKiteScene.triggered.connect(
self.onExportScene)
self.actionChangeExtent.triggered.connect(
self.extentDialog)
self.actionLoadReferenceScene.triggered.connect(
self.onLoadReferenceScene)
self.actionConfiguration.triggered.connect(
self.configDialog)
self.actionHelp.triggered.connect(
lambda: QtGui.QDesktopServices.openUrl('http://pyrocko.org'))
self.actionAbout_Talpa.triggered.connect(
self.aboutDialog().show)
self.actionLog.triggered.connect(
self.log.show)
self.sandbox.sigModelChanged.connect(
self.createMisfitWindow)
self.progress = QtGui.QProgressDialog('', None, 0, 0, self)
self.progress.setValue(0)
self.progress.closeEvent = lambda ev: ev.ignore()
self.progress.setMinimumWidth(400)
self.progress.setWindowTitle('processing...')
self.sandbox.sigProcessingFinished.connect(
self.processingFinished)
self.sandbox.sigProcessingStarted.connect(
self.processingStarted)
if filename is not None:
self.loadModel(filename)
self.createView(self.sandbox)
def __init__(self, *args, **kwargs):
QtGui.QMainWindow.__init__(self, *args, **kwargs)
self.loadUi()
self.views = [KiteScene, KiteQuadtree, KiteCovariance]
self.ptree = KiteParameterTree(showHeader=False)
self.ptree_dock = QtGui.QDockWidget('Parameters', self)
self.ptree_dock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable |
QtGui.QDockWidget.DockWidgetMovable)
self.ptree_dock.setWidget(self.ptree)
self.addDockWidget(
QtCore.Qt.LeftDockWidgetArea, self.ptree_dock)
self.model = SceneModel()
self.model.sigSceneModelChanged.connect(
self.buildViews)
self.sigLoadFile.connect(
self.model.loadFile)
self.sigImportFile.connect(
self.model.importFile)
self.sigLoadConfig.connect(
self.model.loadConfig)
self.sigExportWeightMatrix.connect(
self.model.exportWeightMatrix)
self.actionSave_config.triggered.connect(
self.onSaveConfig)
self.actionSave_scene.triggered.connect(
self.onSaveScene)
self.actionLoad_config.triggered.connect(
self.onLoadConfig)
self.actionLoad_scene.triggered.connect(
self.onOpenScene)
self.actionImport_scene.triggered.connect(
self.onImportScene)
self.actionExport_quadtree.triggered.connect(
self.onExportQuadtree)
self.actionExport_weights.triggered.connect(
self.onExportWeightMatrix)
self.actionAbout_Spool.triggered.connect(
self.aboutDialog().show)
self.actionHelp.triggered.connect(
lambda: QtGui.QDesktopServices.openUrl('http://pyrocko.org'))
self.log = SceneLog(self, self.model)
self.actionLog.triggered.connect(
self.log.show)
self.progress = QtGui.QProgressDialog('', None, 0, 0, self)
self.progress.setValue(0)
self.progress.closeEvent = lambda ev: ev.ignore()
self.progress.setMinimumWidth(400)
self.progress.setWindowTitle('processing...')
self.model.sigProcessingFinished.connect(self.progress.reset)
def __init__(self, parent = None):
path = os.path.dirname(ui.__file__)
# chat
self.message_window_path = os.path.join(path, "message_window.ui")
self.chat_main_path = os.path.join(path, "chat_dialog.ui")
self.chat_add_topic_path = os.path.join(path, "chat_add_topic.ui")
self.chat_img_viewer_path = os.path.join(path, "chat_img_viewer.ui")
# moduls
self.db_studio = db.studio()
self.db_artist = db.artist()
self.db_task = db.task()
self.db_log = db.log()
self.db_chat = db.chat()
# get data
home_dir = os.path.expanduser('~')
json_path = os.path.normpath(os.path.join(home_dir, '.blend_chat.json'))
with open(json_path, 'r') as read:
data_dict = json.load(read)
self.chat_status = 'user'
self.current_task = data_dict['current_task']
self.current_user = data_dict['current_user']
self.current_project = data_dict['current_project']
print(data_dict)
# create widget
QtGui.QMainWindow.__init__(self, parent)
self.setWindowTitle('Chat Message Window')
self.textBox = QtGui.QTextEdit(parent = self)
self.textBox.setReadOnly(True)
self.setCentralWidget(self.textBox)
'''
# test text
text = self.textBox.toPlainText()
text = text + '\n' + '>>> ' + 'text.text'
self.textBox.setPlainText(text)
'''
self.run_chat_ui()