def createNavigationByPage(self): systembuttons = ['Min', 'Max', 'Close'] navbutton = windowsoptions['mainwindow']['centralwindow']['pagetags'][ 0] + systembuttons navbutton_zh = windowsoptions['mainwindow']['centralwindow'][ 'pagetags_zh'] self.navigation = QtGui.QWidget() navigationLayout = QtGui.QHBoxLayout() for item in navbutton: button = item + 'Button' if item not in systembuttons: setattr(self, button, QtGui.QPushButton(navbutton_zh[item])) getattr(self, button).clicked.connect(self.parent.childpageChange) else: setattr(self, button, QtGui.QPushButton()) getattr(self, button).setObjectName(button) navigationLayout.addWidget(getattr(self, button)) self.navigation.setLayout(navigationLayout) self.navigation.setMaximumHeight(60) self.navigation.setContentsMargins(0, 0, 0, 0) getattr(self, 'Min' + 'Button').clicked.connect( self.parent.parent().showMinimized) getattr(self, 'Max' + 'Button').clicked.connect( self.parent.parent().windowMaxNormal) getattr(self, 'Close' + 'Button').clicked.connect(self.parent.parent().close)
def __init__(self, styleoptions, parent=None): super(LoginDialog, self).__init__(styleoptions, parent) self.login_np = QtGui.QWidget() login_np_mainlayout = QtGui.QGridLayout() login_nameLabel = QtGui.QLabel(u'用户名') self.login_name = QtGui.QLineEdit(self) self.login_name.setPlaceholderText(u'用户名') login_passwordLabel = QtGui.QLabel(u'密码') self.login_password = QtGui.QLineEdit(self) self.login_password.setEchoMode(QtGui.QLineEdit.Password) self.login_password.setPlaceholderText(u'密码') login_np_mainlayout.addWidget(login_nameLabel, 0, 0) login_np_mainlayout.addWidget(self.login_name, 0, 1) login_np_mainlayout.addWidget(login_passwordLabel, 1, 0) login_np_mainlayout.addWidget(self.login_password, 1, 1) self.login_np.setLayout(login_np_mainlayout) #确认按钮布局 self.enterwidget = QtGui.QWidget() self.pbLogin = QtGui.QPushButton(u'登录', self) self.pbCancel = QtGui.QPushButton(u'取消', self) self.pbLogin.clicked.connect(self.login) self.pbCancel.clicked.connect(self.reject) enterwidget_mainlayout = QtGui.QGridLayout() enterwidget_mainlayout.addWidget(self.pbLogin, 0, 0) enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1) self.enterwidget.setLayout(enterwidget_mainlayout) self.layout().addWidget(self.login_np) self.layout().addWidget(self.enterwidget) self.resize(self.width(), self.height())
def __init__(self, styleoptions, parent=None): super(numinputDialog, self).__init__(styleoptions, parent) # url内容输入 self.numwidget = QtGui.QWidget() num_mainlayout = QtGui.QGridLayout() self.numLabel = QtGui.QLabel(u'Q的防区个数:') self.numspinbox = QtGui.QSpinBox(self.numwidget) self.ipLabel = QtGui.QLabel(u'Q的下位机IP:') self.ipIn = QtGui.QLineEdit() num_mainlayout.addWidget(self.numLabel, 0, 0) num_mainlayout.addWidget(self.numspinbox, 0, 1) #num_mainlayout.addWidget(self.ipLabel, 1, 0) #num_mainlayout.addWidget(self.ipIn, 1, 1) self.numwidget.setLayout(num_mainlayout) #确认按钮布局 self.enterwidget = QtGui.QWidget() self.pbEnter = QtGui.QPushButton(u'确定', self) self.pbCancel = QtGui.QPushButton(u'取消', self) self.pbEnter.clicked.connect(self.enter) self.pbCancel.clicked.connect(self.reject) enterwidget_mainlayout = QtGui.QGridLayout() enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0) enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1) self.enterwidget.setLayout(enterwidget_mainlayout) self.layout().addWidget(self.numwidget) self.layout().addWidget(self.enterwidget) self.resize(self.width(), self.height())
def __init__(self, styleoptions, parent=None): super(IPaddressDialog, self).__init__(styleoptions, parent) # url内容输入 self.urlwidget = QtGui.QWidget() ip_mainlayout = QtGui.QGridLayout() self.ipLabel = QtGui.QLabel(u'输入主机ip:') self.ipLineEdit = QtGui.QLineEdit(u'192.168.100.100') self.ipLineEdit.setInputMask('000.000.000.000') self.portLabel = QtGui.QLabel(u'输入主机port:') self.portLineEdit = QtGui.QLineEdit(u'8000') ip_mainlayout.addWidget(self.ipLabel, 0, 0) ip_mainlayout.addWidget(self.ipLineEdit, 0, 1) ip_mainlayout.addWidget(self.portLabel, 1, 0) ip_mainlayout.addWidget(self.portLineEdit, 1, 1) self.urlwidget.setLayout(ip_mainlayout) #确认按钮布局 self.enterwidget = QtGui.QWidget() self.pbEnter = QtGui.QPushButton(u'确定', self) self.pbCancel = QtGui.QPushButton(u'取消', self) self.pbEnter.clicked.connect(self.enter) self.pbCancel.clicked.connect(self.reject) enterwidget_mainlayout = QtGui.QGridLayout() enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0) enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1) self.enterwidget.setLayout(enterwidget_mainlayout) self.layout().addWidget(self.urlwidget) self.layout().addWidget(self.enterwidget) self.resize(self.width(), self.height())
def __init__(self, styleoptions, parent=None): super(UrlinputDialog, self).__init__(styleoptions, parent) # url内容输入 self.urlwidget = QtGui.QWidget() url_mainlayout = QtGui.QGridLayout() self.urlLabel = QtGui.QLabel(u'请输入需要访问的url:') self.urlLineEdit = QtGui.QLineEdit(u'http://192.168.10.135:8000/webs/protection_areas/list') url_mainlayout.addWidget(self.urlLabel, 0, 0) url_mainlayout.addWidget(self.urlLineEdit, 1, 0) self.urlwidget.setLayout(url_mainlayout) #确认按钮布局 self.enterwidget = QtGui.QWidget() self.pbEnter = QtGui.QPushButton(u'确定', self) self.pbCancel = QtGui.QPushButton(u'取消', self) self.pbEnter.clicked.connect(self.enter) self.pbCancel.clicked.connect(self.reject) enterwidget_mainlayout = QtGui.QGridLayout() enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0) enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1) self.enterwidget.setLayout(enterwidget_mainlayout) self.layout().addWidget(self.urlwidget) self.layout().addWidget(self.enterwidget) self.resize(self.width(), self.height())
def createcontrolbar(self): self.controlbar = QtGui.QWidget() controlbar_layout = QtGui.QGridLayout() self.pageLabel = QtGui.QLabel() exportmarkdownButton = QtGui.QPushButton(u'导出md') exportmarkdownButton.setObjectName('ExpmarkdownButton') exportmarkdownButton.setToolTip(u'导出md') self.exportmarkdownButton = exportmarkdownButton exporthtmlButton = QtGui.QPushButton(u'导出HTML') exporthtmlButton.setObjectName('ExphtmlButton') exporthtmlButton.setToolTip(u'导出') self.exporthtmlButton = exporthtmlButton exportpdfButton = QtGui.QPushButton(u'导出PDF') exportpdfButton.setObjectName('ExppdfButton') exportpdfButton.setToolTip(u'导出PDF') self.exportpdfButton = exportpdfButton n = 15 blank1 = 3 blank2 = 3 for i in xrange(blank1): controlbar_layout.addWidget(QtGui.QLabel(), 0, i) themes = [ item[5:] for item in windowsoptions['markdownthemes']['themes'] ] for item in themes: button = 'Theme%sButton' % item setattr(self, button, QtGui.QPushButton(item)) getattr(self, button).setObjectName(button) controlbar_layout.addWidget(getattr(self, button), 0, themes.index(item) + blank1) getattr(self, button).clicked.connect(self.settheme) for i in xrange(len(themes) + blank1, len(themes) + blank1 + blank2): controlbar_layout.addWidget(QtGui.QLabel(), 0, i) controlbar_layout.addWidget(exportmarkdownButton, 0, n - 4) controlbar_layout.addWidget(exporthtmlButton, 0, n - 3) controlbar_layout.addWidget(exportpdfButton, 0, n - 2) controlbar_layout.addWidget(QtGui.QLabel(), 0, n) self.controlbar.setLayout(controlbar_layout) controlbar_layout.setContentsMargins(0, 0, 0, 0) self.controlbar.setMaximumHeight(50) exportmarkdownButton.clicked.connect(self.exportmarkdown) exporthtmlButton.clicked.connect(self.exporthtml) exportpdfButton.clicked.connect(self.exportpdf)
def __init__(self, text, styleoptions, parent=None): super(ConfirmDialog, self).__init__(styleoptions, parent) # message内容提示 self.msglabel = QtGui.QLabel(text) self.msglabel.setAlignment(QtCore.Qt.AlignCenter) #确认按钮布局 self.enterwidget = QtGui.QWidget() self.pbEnter = QtGui.QPushButton(u'确定', self) self.pbCancel = QtGui.QPushButton(u'取消', self) self.pbEnter.clicked.connect(self.enter) self.pbCancel.clicked.connect(self.close) enterwidget_mainlayout = QtGui.QGridLayout() enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0) enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1) self.enterwidget.setLayout(enterwidget_mainlayout) self.layout().addWidget(self.msglabel) self.layout().addWidget(self.enterwidget) self.resize(self.width(), self.height())
def createNavigation(self): navbutton = ['Navigation', 'Back', 'Forward', 'Min', 'Max', 'Close'] navbutton_zh = { 'Navigation': u'导航主页(Navigation)', 'Back': u'后退(Back)', 'Forward': u'前进(Forward)', 'Min': u'', 'Max': u'', 'Close': u'' } self.navigation = QtGui.QWidget() navigationLayout = QtGui.QHBoxLayout() for item in navbutton: button = item + 'Button' if item not in ['Min', 'Max', 'Close']: setattr(self, button, QtGui.QPushButton(navbutton_zh[item])) else: setattr(self, button, QtGui.QPushButton()) getattr(self, button).setMaximumWidth(50) getattr(self, button).setObjectName(button) navigationLayout.addWidget(getattr(self, button)) self.navigation.setLayout(navigationLayout) self.navigation.setMaximumHeight(60) self.navigation.setContentsMargins(0, 0, 0, 0) getattr(self, 'Navigation' + 'Button').clicked.connect( self.parent.backnavigationPage) getattr(self, 'Back' + 'Button').clicked.connect(self.parent.backPage) getattr(self, 'Forward' + 'Button').clicked.connect( self.parent.forwardnextPage) getattr(self, 'Min' + 'Button').clicked.connect( self.parent.parent().showMinimized) getattr(self, 'Max' + 'Button').clicked.connect( self.parent.parent().windowMaxNormal) getattr(self, 'Close' + 'Button').clicked.connect(self.parent.parent().close)
def __init__(self, styleoptions, parent=None): super(ExitDialog, self).__init__(styleoptions, parent) # 退出设置 self.exitoptwidget = QtGui.QWidget() exit_mainlayout = QtGui.QGridLayout() self.exitradiogroup = QtGui.QButtonGroup(self.exitoptwidget) self.minRadio = QtGui.QRadioButton(u'最小化') self.exitRadio = QtGui.QRadioButton(u'退出') self.exitsaveRadio = QtGui.QRadioButton(u'退出并保存配置') self.exitradiogroup.addButton(self.minRadio) self.exitradiogroup.addButton(self.exitRadio) self.exitradiogroup.addButton(self.exitsaveRadio) exit_mainlayout.addWidget(self.minRadio, 0, 0) exit_mainlayout.addWidget(self.exitRadio, 1, 0) exit_mainlayout.addWidget(self.exitsaveRadio, 2, 0) self.exitoptwidget.setLayout(exit_mainlayout) self.exitsaveRadio.setChecked(True) #确认按钮布局 self.enterwidget = QtGui.QWidget() self.pbEnter = QtGui.QPushButton(u'确定', self) self.pbCancel = QtGui.QPushButton(u'取消', self) self.pbEnter.clicked.connect(self.exit) self.pbCancel.clicked.connect(self.close) enterwidget_mainlayout = QtGui.QGridLayout() enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0) enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1) self.enterwidget.setLayout(enterwidget_mainlayout) self.layout().addWidget(self.exitoptwidget) self.layout().addWidget(self.enterwidget) self.resize(self.width(), self.height()) self.exitflag = {}