Ejemplo n.º 1
0
 def setupUi(self):
     self.setObjectName('BiblesTab')
     super(BiblesTab, self).setupUi()
     self.verse_display_group_box = QtGui.QGroupBox(self.left_column)
     self.verse_display_group_box.setObjectName('verse_display_group_box')
     self.verse_display_layout = QtGui.QFormLayout(
         self.verse_display_group_box)
     self.verse_display_layout.setObjectName('verse_display_layout')
     self.is_verse_number_visible_check_box = QtGui.QCheckBox(
         self.verse_display_group_box)
     self.is_verse_number_visible_check_box.setObjectName(
         'is_verse_number_visible_check_box')
     self.verse_display_layout.addRow(
         self.is_verse_number_visible_check_box)
     self.new_chapters_check_box = QtGui.QCheckBox(
         self.verse_display_group_box)
     self.new_chapters_check_box.setObjectName('new_chapters_check_box')
     self.verse_display_layout.addRow(self.new_chapters_check_box)
     self.display_style_label = QtGui.QLabel(self.verse_display_group_box)
     self.display_style_label.setObjectName('display_style_label')
     self.display_style_combo_box = QtGui.QComboBox(
         self.verse_display_group_box)
     self.display_style_combo_box.addItems(['', '', '', ''])
     self.display_style_combo_box.setObjectName('display_style_combo_box')
     self.verse_display_layout.addRow(self.display_style_label,
                                      self.display_style_combo_box)
     self.layout_style_label = QtGui.QLabel(self.verse_display_group_box)
     self.layout_style_label.setObjectName('layout_style_label')
     self.layout_style_combo_box = QtGui.QComboBox(
         self.verse_display_group_box)
     self.layout_style_combo_box.setObjectName('layout_style_combo_box')
     self.layout_style_combo_box.addItems(['', '', ''])
     self.verse_display_layout.addRow(self.layout_style_label,
                                      self.layout_style_combo_box)
     self.bible_second_check_box = QtGui.QCheckBox(
         self.verse_display_group_box)
     self.bible_second_check_box.setObjectName('bible_second_check_box')
     self.verse_display_layout.addRow(self.bible_second_check_box)
     self.bible_theme_label = QtGui.QLabel(self.verse_display_group_box)
     self.bible_theme_label.setObjectName('BibleTheme_label')
     self.bible_theme_combo_box = QtGui.QComboBox(
         self.verse_display_group_box)
     self.bible_theme_combo_box.setSizeAdjustPolicy(
         QtGui.QComboBox.AdjustToMinimumContentsLength)
     self.bible_theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                              QtGui.QSizePolicy.Fixed)
     self.bible_theme_combo_box.addItem('')
     self.bible_theme_combo_box.setObjectName('BibleThemecombo_box')
     self.verse_display_layout.addRow(self.bible_theme_label,
                                      self.bible_theme_combo_box)
     self.change_note_label = QtGui.QLabel(self.verse_display_group_box)
     self.change_note_label.setWordWrap(True)
     self.change_note_label.setObjectName('change_note_label')
     self.verse_display_layout.addRow(self.change_note_label)
     self.left_layout.addWidget(self.verse_display_group_box)
     self.scripture_reference_group_box = QtGui.QGroupBox(self.left_column)
     self.scripture_reference_group_box.setObjectName(
         'scripture_reference_group_box')
     self.scripture_reference_layout = QtGui.QGridLayout(
         self.scripture_reference_group_box)
     self.verse_separator_check_box = QtGui.QCheckBox(
         self.scripture_reference_group_box)
     self.verse_separator_check_box.setObjectName(
         'verse_separator_check_box')
     self.scripture_reference_layout.addWidget(
         self.verse_separator_check_box, 0, 0)
     self.verse_separator_line_edit = QtGui.QLineEdit(
         self.scripture_reference_group_box)
     self.verse_separator_line_edit.setObjectName(
         'verse_separator_line_edit')
     self.scripture_reference_layout.addWidget(
         self.verse_separator_line_edit, 0, 1)
     self.range_separator_check_box = QtGui.QCheckBox(
         self.scripture_reference_group_box)
     self.range_separator_check_box.setObjectName(
         'range_separator_check_box')
     self.scripture_reference_layout.addWidget(
         self.range_separator_check_box, 1, 0)
     self.range_separator_line_edit = QtGui.QLineEdit(
         self.scripture_reference_group_box)
     self.range_separator_line_edit.setObjectName(
         'range_separator_line_edit')
     self.scripture_reference_layout.addWidget(
         self.range_separator_line_edit, 1, 1)
     self.list_separator_check_box = QtGui.QCheckBox(
         self.scripture_reference_group_box)
     self.list_separator_check_box.setObjectName('list_separator_check_box')
     self.scripture_reference_layout.addWidget(
         self.list_separator_check_box, 2, 0)
     self.list_separator_line_edit = QtGui.QLineEdit(
         self.scripture_reference_group_box)
     self.list_separator_line_edit.setObjectName('list_separator_line_edit')
     self.scripture_reference_layout.addWidget(
         self.list_separator_line_edit, 2, 1)
     self.end_separator_check_box = QtGui.QCheckBox(
         self.scripture_reference_group_box)
     self.end_separator_check_box.setObjectName('end_separator_check_box')
     self.scripture_reference_layout.addWidget(self.end_separator_check_box,
                                               3, 0)
     self.end_separator_line_edit = QtGui.QLineEdit(
         self.scripture_reference_group_box)
     self.end_separator_line_edit.setObjectName('end_separator_line_edit')
     self.end_separator_line_edit.setValidator(
         QtGui.QRegExpValidator(QtCore.QRegExp(r'[^0-9]*'),
                                self.end_separator_line_edit))
     self.scripture_reference_layout.addWidget(self.end_separator_line_edit,
                                               3, 1)
     self.left_layout.addWidget(self.scripture_reference_group_box)
     self.right_column.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                     QtGui.QSizePolicy.Preferred)
     self.language_selection_group_box = QtGui.QGroupBox(self.right_column)
     self.language_selection_group_box.setObjectName(
         'language_selection_group_box')
     self.language_selection_layout = QtGui.QVBoxLayout(
         self.language_selection_group_box)
     self.language_selection_label = QtGui.QLabel(
         self.language_selection_group_box)
     self.language_selection_label.setObjectName('language_selection_label')
     self.language_selection_combo_box = QtGui.QComboBox(
         self.language_selection_group_box)
     self.language_selection_combo_box.setObjectName(
         'language_selection_combo_box')
     self.language_selection_combo_box.addItems(['', '', ''])
     self.language_selection_layout.addWidget(self.language_selection_label)
     self.language_selection_layout.addWidget(
         self.language_selection_combo_box)
     self.right_layout.addWidget(self.language_selection_group_box)
     self.left_layout.addStretch()
     self.right_layout.addStretch()
     # Signals and slots
     self.is_verse_number_visible_check_box.stateChanged.connect(
         self.on_is_verse_number_visible_check_box_changed)
     self.new_chapters_check_box.stateChanged.connect(
         self.on_new_chapters_check_box_changed)
     self.display_style_combo_box.activated.connect(
         self.on_display_style_combo_box_changed)
     self.bible_theme_combo_box.activated.connect(
         self.on_bible_theme_combo_box_changed)
     self.layout_style_combo_box.activated.connect(
         self.on_layout_style_combo_box_changed)
     self.bible_second_check_box.stateChanged.connect(
         self.on_bible_second_check_box)
     self.verse_separator_check_box.clicked.connect(
         self.on_verse_separator_check_box_clicked)
     self.verse_separator_line_edit.textEdited.connect(
         self.on_verse_separator_line_edit_edited)
     self.verse_separator_line_edit.editingFinished.connect(
         self.on_verse_separator_line_edit_finished)
     self.range_separator_check_box.clicked.connect(
         self.on_range_separator_check_box_clicked)
     self.range_separator_line_edit.textEdited.connect(
         self.on_range_separator_line_edit_edited)
     self.range_separator_line_edit.editingFinished.connect(
         self.on_range_separator_line_edit_finished)
     self.list_separator_check_box.clicked.connect(
         self.on_list_separator_check_box_clicked)
     self.list_separator_line_edit.textEdited.connect(
         self.on_list_separator_line_edit_edited)
     self.list_separator_line_edit.editingFinished.connect(
         self.on_list_separator_line_edit_finished)
     self.end_separator_check_box.clicked.connect(
         self.on_end_separator_check_box_clicked)
     self.end_separator_line_edit.textEdited.connect(
         self.on_end_separator_line_edit_edited)
     self.end_separator_line_edit.editingFinished.connect(
         self.on_end_separator_line_edit_finished)
     Registry().register_function('theme_update_list',
                                  self.update_theme_list)
     self.language_selection_combo_box.activated.connect(
         self.on_language_selection_combo_box_changed)
Ejemplo n.º 2
0
    def setUp_profile(self):
        emp = self.fetch_employee()
        userx = self.db.get_user_info(emp['user'])
        profile = self.fetch_profile()
        config = self.fetch_config()

        label_color = "<font color='#0f7a62'>%s</font>"
        lbl_text_green = "<font color='green'>%s</font>"
        lbl_text_warning = "<font color='orangered'>%s</font>"
        lbl_text_red = "<font color='red'>%s</font>"
        # font_style = "QLabel {font: Arial}"

        # Profile Information
        if emp['is_active'] is False:
            status = 'Inactive'
            self.lbl_status.setText(self.lbl_status.text() +
                                    lbl_text_red % status)
        else:
            status = 'Active'
            self.lbl_status.setText(self.lbl_status.text() +
                                    lbl_text_green % status)

        # self.lbl_status.setStyleSheet(font_style)

        self.lbl_username.setText(self.lbl_username.text() +
                                  label_color % userx[0])

        self.lbl_name_2.setText(self.lbl_name_2.text() + \
                                lbl_text_green % '%s, %s %s'.capitalize() %
                                (emp['last_name'], emp['first_name'], emp['middle_name']))

        self.name_full = '%s, %s %s'.capitalize() % (
            emp['last_name'], emp['first_name'], emp['middle_name'])

        self.lbl_id.setText(self.lbl_id.text() + \
                            lbl_text_green % sp.convert_id(emp['id'], emp['start_date'][:4]))

        birthday = parse(profile['birthday']).astimezone(time_zone)
        birthday = birthday.strftime("%b %d, %Y")

        self.lbl_bday.setText(self.lbl_bday.text() + label_color % birthday)

        self.lbl_gender.setText(self.lbl_gender.text() +
                                label_color % profile['gender'].capitalize())

        self.lbl_address.setText(self.lbl_address.text() + \
                                 label_color % "<font size=2>%s</font>" % profile['address'].capitalize())

        self.lbl_gmail.setText(self.lbl_gmail.text() + label_color %
                               "<font size=2>%s</font>" % userx[1])

        self.lbl_contact.setText(self.lbl_contact.text() +
                                 label_color % profile['contact_number'])
        # self.lbl_contact.setStyleSheet(font_style)

        self.lbl_height.setText(self.lbl_height.text() +
                                label_color % str(profile['height']))

        age = int(datetime.now().strftime('%Y')) - int(profile['birthday'][:4])
        self.lbl_age.setText(self.lbl_age.text() + label_color % str(age))

        date_joined = parse(emp['start_date']).astimezone(time_zone)
        date_joined = date_joined.strftime("%b %d, %Y")

        self.lbl_start_date.setText(self.lbl_start_date.text() +
                                    label_color % date_joined)

        self.lbl_presence_count.setText(self.lbl_presence_count.text() + \
                                        lbl_text_green % str(profile['presences_count']))

        abstext_color = lbl_text_green
        if profile['absences_count'] > 0:
            abstext_color = lbl_text_warning

        elif profile['absences_count'] > 10:
            abstext_color = lbl_text_red

        self.lbl_absence_count.setText(self.lbl_absence_count.text() + \
                                       abstext_color % str(profile['absences_count']))

        # Job Information
        self.lbl_position.setText(self.lbl_position.text() +
                                  label_color % emp['position'].capitalize())
        self.position = emp['position']

        self.lbl_rate.setText(self.lbl_rate.text() + label_color %
                              "PHP %s/hour" % str(config['rate_per_hour']))

        self.lbl_dayoff.setText(self.lbl_dayoff.text() +
                                label_color % config['non_working_days'])

        self.lbl_sss.setText(self.lbl_sss.text() +
                             label_color % config['sss_number'])

        self.lbl_philhealth.setText(self.lbl_philhealth.text() +
                                    label_color % config['philhealth_number'])

        self.lbl_pagibig.setText(self.lbl_pagibig.text() +
                                 label_color % config['pagibig_number'])

        self.lbl_tin.setText(self.lbl_tin.text() +
                             label_color % config['tin_number'])

        self.lbl_profile_photo.setPixmap(
            QtGui.QPixmap(_fromUtf8("profilepics/%s.png" % str(userx[2]))))
        self.lbl_profile_photo.setScaledContents(True)
        self.lbl_profile_photo.setObjectName(_fromUtf8("lbl_profile_photo"))

        # populate update text boxes
        self.fname_txt.setText(emp['first_name'].capitalize())
        self.mname_txt.setText(emp['middle_name'].capitalize())
        self.lname_txt.setText(emp['last_name'].capitalize())
        self.contact_txt.setText(profile['contact_number'])
        self.address_txt.setText(profile['address'].capitalize())
        bday = profile['birthday'].split('-')
        self.birthday_txt.setDate(
            QtCore.QDate(int(bday[0]), int(bday[1]), int(bday[2])))

        self.male_radio.setChecked(True)
        if profile['gender'] != 'male':
            self.female_radio.setChecked(True)
        self.height_txt.setText(str(profile['height']))

        self.active_radio.setChecked(True)
        if emp['is_active'] is False:
            self.inactive_radio.setChecked(True)

        if 'monday' in config['non_working_days']:
            self.checkBox_mon.setChecked(True)
        if 'tuesday' in config['non_working_days']:
            self.checkBox_tue.setChecked(True)
        if 'wednesday' in config['non_working_days']:
            self.checkBox_wed.setChecked(True)
        if 'thursday' in config['non_working_days']:
            self.checkBox_thu.setChecked(True)
        if 'friday' in config['non_working_days']:
            self.checkBox_fri.setChecked(True)
        if 'saturday' in config['non_working_days']:
            self.checkBox_sat.setChecked(True)

        position_lists = ['instructor', 'administrator']
        for i in position_lists:
            self.position_combo.addItem(i)
        if emp['is_admin']:
            self.position_combo.setCurrentIndex(1)

        global_conf = self.db.get_config()[0]

        rates_list = [
            global_conf['level_1_rate'], global_conf['level_2_rate'],
            global_conf['level_3_rate']
        ]
        for i in range(3):
            self.rate_combo.addItem('PHP ' + str(rates_list[i]))
            if config['rate_per_hour'] == rates_list[i]:
                self.rate_combo.setCurrentIndex(i)

        self.sss_txt.setText(config['sss_number'])
        self.philhealth_txt.setText(config['philhealth_number'])
        self.pagibig_txt.setText(config['pagibig_number'])
        self.tin_txt.setText(config['tin_number'])

        regex_letter = QtCore.QRegExp("([a-zA-Z]+[ ])+")
        validator_letter = QtGui.QRegExpValidator(regex_letter)

        regex_contact = QtCore.QRegExp("^9(?!(000000000))\d{9}$")
        validator_contact = QtGui.QRegExpValidator(regex_contact)

        regex_sss = QtCore.QRegExp(
            "^(?!(00))\d{2}-(?!(000000000))\d{9}-(?!(0))\d{1}$")
        validator_sss = QtGui.QRegExpValidator(regex_sss)

        regex_philhealth = QtCore.QRegExp(
            "^(?!(00))\d{2}-(?!(000000000))\d{9}-(?!(0))\d{1}$")
        validator_philhealth = QtGui.QRegExpValidator(regex_philhealth)

        regex_pagibig = QtCore.QRegExp(
            "^(?!(0000))\d{4}-(?!(0000))\d{4}-(?!(0000))\d{4}$")
        validator_pagibig = QtGui.QRegExpValidator(regex_pagibig)

        regex_tin = QtCore.QRegExp(
            "^(?!(000))\d{3}-(?!(000))\d{3}-(?!(000))\d{3}-(?!(00000))\d{5}$")
        validator_tin = QtGui.QRegExpValidator(regex_tin)

        regex_height = QtCore.QRegExp("^1(?!([1, 2, 9, 0]))\d{1}(?!(0))\d{1}$")
        validator_height = QtGui.QRegExpValidator(regex_height)

        self.fname_txt.setValidator(validator_letter)
        self.fname_txt.setMaxLength(35)
        self.mname_txt.setValidator(validator_letter)
        self.mname_txt.setMaxLength(35)
        self.lname_txt.setValidator(validator_letter)
        self.lname_txt.setMaxLength(35)

        self.height_txt.setValidator(validator_height)
        self.contact_txt.setValidator(validator_contact)
        self.sss_txt.setValidator(validator_sss)
        self.philhealth_txt.setValidator(validator_philhealth)
        self.pagibig_txt.setValidator(validator_pagibig)
        self.tin_txt.setValidator(validator_tin)
	def out_frame_func(int_lng, prj_path, mesh_name_txt, patches_visible): 
		patches_2_obj = None
		
		#----------------Если файл patches_2.pkl существует, получаем данные из него для вывода в форму---------------#
		
		if patches_visible == True:
			patches_2_path_file = prj_path + '/' + mesh_name_txt + '/' + 'patches_2.pkl'
			if os.path.exists(patches_2_path_file):
		
				input = open(patches_2_path_file, 'rb')
				patches_2_obj = pickle.load(input)
				input.close()
					
		main_lbl = QtGui.QLabel()
		if int_lng == 'Russian':
			main_lbl.setText("Список граней для патчей")
		elif int_lng == 'English':
			main_lbl.setText("List of faces for patches")
		
		#-------------Формируем внешний вид формы для файла patches_2.pkl на основе данных файла patches_1.pkl----------#
		
		patches_1_path_file = prj_path + '/' + mesh_name_txt + '/' + 'patches_1.pkl'
		if os.path.exists(patches_1_path_file):
		
			input = open(patches_1_path_file, 'rb')
			obj = pickle.load(input)
			input.close()
			
			k = 1
			i = 0
			
			p_list = []
			fe_main_list = []

			f_vbox = QtGui.QVBoxLayout()
			for el_m in obj:

				p_name = el_m['patch_' + str(k)]
				p_list.append(p_name)
				t_name = el_m['type_' + str(k)]
				f_name = el_m['faces_' + str(k)]		
					
				if el_m['type_' + str(k)] == 'cyclic':
					n_name = el_m['neighb_' + str(k)]
					patch_lbl = QtGui.QLabel("Патч: " + p_name + ", " + "Тип: " + t_name + ", " + "Сосед: " + n_name)
				else:		
					patch_lbl = QtGui.QLabel("Патч: " + p_name + ", " + "Тип: " + t_name)
						
				g = 1
				b = 0
				
				f_grid = QtGui.QGridLayout()
				f_frame = QtGui.QFrame()
				prs_grid = QtGui.QGridLayout()

				fe_pred_main = []
				while g <= f_name:					
					t = 1

					validator = QtGui.QRegExpValidator(QtCore.QRegExp("[0-9]+"))

					f_hbox = QtGui.QHBoxLayout()
					
					fe_list = []
					p = 0
					while t <= 4:
						
						face_edit = QtGui.QLineEdit()
						if t == 1:
							if int_lng == 'Russian':
								face_edit.setToolTip("Метка 1 грани блока, входящей в патч")
							elif int_lng == 'English':
								face_edit.setToolTip("Label 1 of the edge of the block included in the patch")
						elif t == 2:
							if int_lng == 'Russian':
								face_edit.setToolTip("Метка 2 грани блока, входящей в патч")
							elif int_lng == 'English':
								face_edit.setToolTip("Label 2 of the edge of the block included in the patch")
						elif t == 3:
							if int_lng == 'Russian':
								face_edit.setToolTip("Метка 3 грани блока, входящей в патч")
							elif int_lng == 'English':
								face_edit.setToolTip("Label 3 of the edge of the block included in the patch")
						elif t == 4:
							if int_lng == 'Russian':
								face_edit.setToolTip("Метка 4 грани блока, входящей в патч")
							elif int_lng == 'English':
								face_edit.setToolTip("Label 4 of the edge of the block included in the patch")
						if patches_2_obj != None:
							face_edit.setText(patches_2_obj[i][p_name][b][p])
						face_edit.setFixedSize(30, 21)
						face_edit.setValidator(validator)
						f_hbox.addWidget(face_edit)
						fe_list.append(face_edit)
						t = t + 1
						p = p + 1
						
					if f_name == 1 and g == 1:				
						f_grid.addLayout(f_hbox, b, 0)
						fe_main_list.append(fe_list)
					else:
						f_grid.addLayout(f_hbox, b, 0)
						fe_pred_main.append(fe_list)
				
					g = g + 1
					b = b + 1
				if fe_pred_main != []:	
					fe_main_list.append(fe_pred_main)
						
				prs_grid.addLayout(f_grid, 0, 0)
				prs_grid.addWidget(patch_lbl, 0, 1)
				f_frame.setLayout(prs_grid)
				f_vbox.addWidget(f_frame)
					
				k = k + 1
				i = i + 1
			
			prs_frame = QtGui.QFrame()
			prs_frame.setLayout(f_vbox)
				
			# -----------------------Кнопка сохранения------------------------#

			patches_2_btnSave = QtGui.QPushButton()
			patches_2_btnSave.setFixedSize(80, 25)
			buttons_hbox = QtGui.QHBoxLayout()
			buttons_hbox.addWidget(patches_2_btnSave)
			if int_lng == 'Russian':
				patches_2_btnSave.setText("Записать")
			elif int_lng == 'English':
				patches_2_btnSave.setText("Write")
			
			# ---------------------Групповой элемент формы--------------------#

			patches_2_grid = QtGui.QGridLayout()
			patches_2_grid.addWidget(main_lbl, 0, 0, alignment=QtCore.Qt.AlignCenter)
			patches_2_grid.addWidget(prs_frame, 1, 0, alignment=QtCore.Qt.AlignCenter)
			patches_2_grid.addLayout(buttons_hbox, 2, 0, alignment=QtCore.Qt.AlignCenter)
			patches_2_grid.setRowStretch(3, 6)
			patches_2_group = QtGui.QGroupBox()
			patches_2_group.setLayout(patches_2_grid)
				
			return patches_2_group, patches_2_btnSave, p_list, fe_main_list
Ejemplo n.º 4
0
    def setupUi(self, MainWindow):
        #Frame da Janela
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.setFixedSize(801, 592)
        MainWindow.setWindowIcon(QtGui.QIcon("Fotos/carro.jpg"))
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))

        #Cor da janela (ativa,inativa,desativada)
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(240, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(240, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(240, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(240, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
        MainWindow.setPalette(palette)

        #########LABELS#######################################
        self.nomelabel = QtGui.QLabel(self.centralwidget)
        self.nomelabel.setGeometry(QtCore.QRect(40, 120, 111, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(12)
        self.nomelabel.setFont(font)
        self.nomelabel.setObjectName(_fromUtf8("nomelabel"))
        self.celularlabel = QtGui.QLabel(self.centralwidget)
        self.celularlabel.setGeometry(QtCore.QRect(40, 180, 111, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(12)
        self.celularlabel.setFont(font)
        self.celularlabel.setObjectName(_fromUtf8("celularlabel"))
        self.emaillabel = QtGui.QLabel(self.centralwidget)
        self.emaillabel.setGeometry(QtCore.QRect(40, 240, 111, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(12)
        self.emaillabel.setFont(font)
        self.emaillabel.setObjectName(_fromUtf8("emaillabel"))
        self.usuariolabel = QtGui.QLabel(self.centralwidget)
        self.usuariolabel.setGeometry(QtCore.QRect(40, 300, 111, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(12)
        self.usuariolabel.setFont(font)
        self.usuariolabel.setObjectName(_fromUtf8("usuariolabel"))
        self.senhalabel = QtGui.QLabel(self.centralwidget)
        self.senhalabel.setGeometry(QtCore.QRect(40, 360, 111, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(12)
        self.senhalabel.setFont(font)
        self.senhalabel.setObjectName(_fromUtf8("senhalabel"))
        self.confirmarsenhalabel = QtGui.QLabel(self.centralwidget)
        self.confirmarsenhalabel.setGeometry(QtCore.QRect(40, 420, 121, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(12)
        self.confirmarsenhalabel.setFont(font)
        self.confirmarsenhalabel.setObjectName(
            _fromUtf8("confirmarsenhalabel"))
        self.cadastrotitulo = QtGui.QLabel(self.centralwidget)
        self.cadastrotitulo.setGeometry(QtCore.QRect(260, 40, 271, 61))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Bodoni MT"))
        font.setPointSize(48)
        self.cadastrotitulo.setFont(font)
        self.cadastrotitulo.setObjectName(_fromUtf8("cadastrotitulo"))
        ###################FIM DAS LABELS###################################

        self.nomeinput = QtGui.QLineEdit(self.centralwidget)
        self.nomeinput.setGeometry(QtCore.QRect(170, 130, 491, 20))
        self.nomeinput.setObjectName(_fromUtf8("nomeinput"))
        reg_exp = QtCore.QRegExp("[a-z-A-Z_ ]+")
        textvalidator = QtGui.QRegExpValidator(reg_exp, self.nomeinput)
        self.nomeinput.setValidator(textvalidator)

        self.celularinput = QtGui.QLineEdit(self.centralwidget)
        numbervalidator = QtGui.QDoubleValidator()
        self.celularinput.setValidator(numbervalidator)
        self.celularinput.setGeometry(QtCore.QRect(170, 190, 491, 20))
        self.celularinput.setInputMask(_fromUtf8(""))
        self.celularinput.setText(_fromUtf8(""))
        self.celularinput.setMaxLength(11)
        self.celularinput.setObjectName(_fromUtf8("celularinput"))
        self.celularinput.setPlaceholderText(
            "Digite seguindo esse exemplo: 11912341234")

        self.emailinput = QtGui.QLineEdit(self.centralwidget)
        self.emailinput.setGeometry(QtCore.QRect(170, 250, 491, 20))
        self.emailinput.setObjectName(_fromUtf8("emailinput"))

        self.usuarioinput = QtGui.QLineEdit(self.centralwidget)
        self.usuarioinput.setGeometry(QtCore.QRect(170, 310, 491, 20))
        self.usuarioinput.setObjectName(_fromUtf8("usuarioinput"))

        self.senhainput = QtGui.QLineEdit(self.centralwidget)
        self.senhainput.setGeometry(QtCore.QRect(170, 370, 491, 20))
        self.senhainput.setEchoMode(QtGui.QLineEdit.Password)
        self.senhainput.setObjectName(_fromUtf8("senhainput"))

        self.confirmarsenhainput = QtGui.QLineEdit(self.centralwidget)
        self.confirmarsenhainput.setGeometry(QtCore.QRect(170, 430, 491, 20))
        self.confirmarsenhainput.setEchoMode(QtGui.QLineEdit.Password)
        self.confirmarsenhainput.setObjectName(
            _fromUtf8("confirmarsenhainput"))

        self.voltar = QtGui.QPushButton(self.centralwidget)
        self.voltar.setGeometry(QtCore.QRect(220, 480, 101, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("MS Shell Dlg 2"))
        font.setPointSize(8)
        self.voltar.setFont(font)
        self.voltar.setObjectName(_fromUtf8("voltar"))
        self.voltar.clicked.connect(self.abrircaronas)

        self.confirmar = QtGui.QPushButton(self.centralwidget)
        self.confirmar.setGeometry(QtCore.QRect(510, 480, 101, 41))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("MS Shell Dlg 2"))
        font.setPointSize(8)
        self.confirmar.setFont(font)
        self.confirmar.setObjectName(_fromUtf8("confirmar"))
        self.confirmar.clicked.connect(self.registrarcadastro)

        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 5
0
 def __init__(self, *args):
     QAbstractSpinBox.__init__(self, *args)
     regexp = QtCore.QRegExp('^0x[0-9A-Fa-f]{1,10}$')
     self.validator = QtGui.QRegExpValidator(regexp)
     self._value = 0
Ejemplo n.º 6
0
    def __init__(self, parent=None):
        super(EELHighlighter, self).__init__(parent)
        self.color_0 = QtGui.QColor(249, 38, 144)
        self.color_1 = QtGui.QColor(102, 217, 239)
        self.color_2 = QtGui.QColor(117, 113, 94)  #comments
        self.color_3 = QtGui.QColor(230, 219, 102)
        self.color_4 = QtGui.QColor(166, 226, 46)
        self.color_5 = QtGui.QColor(174, 129, 255)
        self.color_6 = QtGui.QColor(253, 151, 32)

        group1Format = QtGui.QTextCharFormat()
        group1Format.setForeground(self.color_0)
        group1Patterns = [
            "\\bimport\\b", '\\bif\\b', '\\belse\\b', "\\bfor\\b",
            "\\bswitch\\b", "\\bcase\\b", "\\bbreak\\b", "\\breturn\\b",
            "\\bwhile\\b", "\\blocal\\b"
        ]

        self.highlightingRules = [(QtCore.QRegExp(pattern), group1Format)
                                  for pattern in group1Patterns]

        keywordFormat = QtGui.QTextCharFormat()
        keywordFormat.setForeground(self.color_1)
        words = ["procedure", "table"]
        keywordPatterns = [
            "\\bchar\\b", "\\bclass\\b", "\\bconst\\b", "\\bdouble\\b",
            "\\benum\\b", "\\bexplicit\\b", "\\bfriend\\b", "\\binline\\b",
            "\\bint\\b", "\\blong\\b", "\\bnamespace\\b", "\\boperator\\b",
            "\\bprivate\\b", "\\bprotected\\b", "\\bpublic\\b", "\\bshort\\b",
            "\\bsignals\\b", "\\bsigned\\b", "\\bslots\\b", "\\bstatic\\b",
            "\\bstruct\\b", "\\btemplate\\b", "\\btypedef\\b",
            "\\btypename\\b", "\\bunion\\b", "\\bunsigned\\b", "\\bvirtual\\b",
            "\\bvoid\\b", "\\bvolatile\\b"
        ]
        for word in words:
            keywordPatterns.append("\\b" + word + "\\b")

        self.highlightingRules += [(QtCore.QRegExp(pattern), keywordFormat)
                                   for pattern in keywordPatterns]

        classFormat = QtGui.QTextCharFormat()
        classFormat.setForeground(self.color_4)
        self.highlightingRules.append(
            (QtCore.QRegExp("\\bQ[A-Za-z]+\\b"), classFormat))

        numberFormat = QtGui.QTextCharFormat()
        numberFormat.setForeground(self.color_5)
        numberPatterns = [
            '\\b[+-]?[0-9]+[lL]?\\b', '\\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\\b',
            '\\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b', '\\btrue\\b',
            '\\bfalse\\b'
        ]
        self.highlightingRules += [(QtCore.QRegExp(pattern), numberFormat)
                                   for pattern in numberPatterns]

        singleLineCommentFormat = QtGui.QTextCharFormat()
        singleLineCommentFormat.setForeground(self.color_2)
        self.highlightingRules.append(
            (QtCore.QRegExp("//[^\n]*"), singleLineCommentFormat))

        self.multiLineCommentFormat = QtGui.QTextCharFormat()
        self.multiLineCommentFormat.setForeground(self.color_2)

        quotationFormat = QtGui.QTextCharFormat()
        quotationFormat.setForeground(self.color_3)
        self.highlightingRules.append(
            (QtCore.QRegExp("\".*\""), quotationFormat))

        self.highlightingRules.append(
            (QtCore.QRegExp("<.*>"), quotationFormat))

        functionFormat = QtGui.QTextCharFormat()
        functionFormat.setForeground(self.color_1)
        self.highlightingRules.append(
            (QtCore.QRegExp("\\b[A-Za-z0-9_]+(?=\\()"), functionFormat))

        self.commentStartExpression = QtCore.QRegExp("/\\*")
        self.commentEndExpression = QtCore.QRegExp("\\*/")
    def out_frame_func(int_lng, prj_path, mesh_name_txt, blocks_visible):
        blocks_1_obj = None

        #----------------Если файл blocks_1.pkl существует, получаем данные из него для вывода в форму---------------#

        if blocks_visible == True:
            blocks_1_path_file = prj_path + '/' + mesh_name_txt + '/' + 'blocks_1.pkl'
            if os.path.exists(blocks_1_path_file):

                input = open(blocks_1_path_file, 'rb')
                blocks_1_obj = pickle.load(input)
                input.close()

        #---------------Формируем внешний вид формы для файла blocks_1.pkl на основе данных файла initial.pkl-------------#

        main_lbl = QtGui.QLabel()

        if int_lng == 'Russian':
            main_lbl.setText("Базовое описание блоков")
        elif int_lng == 'English':
            main_lbl.setText("Basic block description")

        initial_path_file = prj_path + '/' + mesh_name_txt + '/' + 'initial.pkl'
        if os.path.exists(initial_path_file):

            input = open(initial_path_file, 'rb')
            obj = pickle.load(input)
            input.close()

            prs_grid_main = QtGui.QGridLayout()

            main_str = QtGui.QVBoxLayout()
            j = 1
            k = 0
            vrs_edit_list = []

            mg_edit_list = []
            mg_lbl_list = []

            napr_lbl_list = []
            napr_edit_list = []
            ks_lbl_list = []
            ks_edit_list = []
            noeG_frame_list = []

            v_1_obsh_list = []
            v_2_obsh_list = []
            vrs_obj_list = []
            j_list = []

            while j <= obj['nob']:

                hex_lbl = QtGui.QLabel("hex")
                a_lbl = QtGui.QLabel("(")
                b_lbl = QtGui.QLabel(")")
                c_lbl = QtGui.QLabel("(")
                d_lbl = QtGui.QLabel(")")

                vrs_edit = QtGui.QComboBox()
                vrs_edit.setFixedSize(100, 25)
                vrs_list = ["simpleGrading", "edgeGrading"]
                vrs_edit.addItems(vrs_list)
                vrs_edit_list.append(vrs_edit)
                if blocks_1_obj != None:
                    for bvc in range(vrs_edit.count()):
                        if vrs_edit.itemText(bvc) == blocks_1_obj[k]['srya_' +
                                                                     str(j)]:
                            vrs_edit.setCurrentIndex(bvc)

                mg_lbl = QtGui.QLabel()
                mg_lbl_list.append(mg_lbl)
                mg_edit = QtGui.QCheckBox()

                if blocks_1_obj != None:
                    mg_edit.setChecked(blocks_1_obj[k]['mg_' + str(j)])
                mg_edit_list.append(mg_edit)

                if int_lng == 'Russian':
                    vrs_edit.setToolTip("Тип описания градуировки")
                    mg_lbl.setText("Мультиградуировка")
                    mg_edit.setToolTip(
                        "Установите флажок для указания опции мультиградуировки"
                    )
                elif int_lng == 'English':
                    vrs_edit.setToolTip("Type of grading")
                    mg_lbl.setText("Multigrading")
                    mg_edit.setToolTip(
                        "Check the box to specify the multigrading option")

                nov_str = QtGui.QHBoxLayout()
                nos_str = QtGui.QHBoxLayout()
                noeG_str = QtGui.QHBoxLayout()

                n = 1
                p = 0
                v_1_list = []
                while n <= 8:

                    v_1_edit = QtGui.QLineEdit()
                    if int_lng == 'Russian':
                        v_1_edit.setToolTip("Метка вершины " + str(n) +
                                            " - неотрицательное число")
                    elif int_lng == 'English':
                        v_1_edit.setToolTip("Label of the vertex " + str(n) +
                                            " - nonnegative number")

                    v_1_edit.setFixedSize(30, 21)
                    if blocks_1_obj != None:
                        v_1_edit.setText(blocks_1_obj[k]['versh_' + str(j)][p])
                    validator = QtGui.QRegExpValidator(
                        QtCore.QRegExp("[0-9]+"))
                    v_1_edit.setValidator(validator)
                    nov_str.insertWidget(n, v_1_edit)
                    v_1_list.append(v_1_edit)
                    n = n + 1
                    p = p + 1

                v_1_obsh_list.append(v_1_list)

                n = 1
                p = 0
                v_2_list = []
                while n <= 3:

                    v_2_edit = QtGui.QLineEdit()
                    if n == 1:
                        if int_lng == 'Russian':
                            v_2_edit.setToolTip(
                                "Число ячеек в направлении x1" +
                                " - неотрицательное число")
                        elif int_lng == 'English':
                            v_2_edit.setToolTip(
                                "Number of cells in x1 direction" +
                                " - nonnegative number")
                    elif n == 2:
                        if int_lng == 'Russian':
                            v_2_edit.setToolTip(
                                "Число ячеек в направлении x2" +
                                " - неотрицательное число")
                        elif int_lng == 'English':
                            v_2_edit.setToolTip(
                                "Number of cells in x2 direction" +
                                " - nonnegative number")
                    elif n == 3:
                        if int_lng == 'Russian':
                            v_2_edit.setToolTip(
                                "Число ячеек в направлении x3" +
                                " - неотрицательное число")
                        elif int_lng == 'English':
                            v_2_edit.setToolTip(
                                "Number of cells in x3 direction" +
                                " - nonnegative number")
                    v_2_edit.setFixedSize(30, 21)
                    if blocks_1_obj != None:
                        v_2_edit.setText(blocks_1_obj[k]['yach_' + str(j)][p])
                    v_2_edit.setValidator(validator)
                    nos_str.insertWidget(n, v_2_edit)
                    v_2_list.append(v_2_edit)
                    n = n + 1
                    p = p + 1

                v_2_obsh_list.append(v_2_list)

                napr_lbl = QtGui.QLabel()
                napr_lbl_list.append(napr_lbl)
                napr_edit = QtGui.QComboBox()
                if blocks_1_obj != None and blocks_1_obj[k]['mg_' +
                                                            str(j)] == True:
                    napr_edit_mas = napr_edit.count()
                    for bvc in range(napr_edit_mas):
                        if napr_edit.itemText(bvc) == blocks_1_obj[k]['napr_' +
                                                                      str(j)]:
                            napr_edit.setCurrentIndex(bvc)

                napr_edit.setFixedSize(50, 25)
                napr_list = ["x", "y", "z"]
                napr_edit.addItems(napr_list)
                napr_edit_list.append(napr_edit)

                ks_lbl = QtGui.QLabel()
                ks_lbl_list.append(ks_lbl)
                ks_edit = QtGui.QSpinBox()
                if blocks_1_obj != None and blocks_1_obj[k]['mg_' +
                                                            str(j)] == True:
                    ks_edit.setValue(blocks_1_obj[k]['ks_' + str(j)])
                ks_edit.setRange(1, 10)
                ks_edit.setFixedSize(50, 25)
                ks_edit_list.append(ks_edit)

                prs_grid = QtGui.QGridLayout()
                prs_grid.addWidget(hex_lbl, 0, 0)
                prs_grid.addWidget(a_lbl, 0, 1)
                prs_grid.addLayout(nov_str, 0, 2)
                prs_grid.addWidget(b_lbl, 0, 3)

                prs_grid.addWidget(c_lbl, 0, 4)
                prs_grid.addLayout(nos_str, 0, 5)
                prs_grid.addWidget(d_lbl, 0, 6)

                prs_grid.addWidget(vrs_edit, 0, 7)
                prs_grid.addWidget(mg_edit, 0, 8)
                prs_grid.addWidget(mg_lbl, 0, 9)

                noeG_str.insertWidget(0, napr_lbl)
                noeG_str.insertWidget(1, napr_edit)
                noeG_str.insertWidget(2, ks_lbl)
                noeG_str.insertWidget(3, ks_edit)

                main_str.addLayout(prs_grid)
                noeG_frame = QtGui.QFrame()
                noeG_frame.setFixedSize(370, 40)
                noeG_frame.setLayout(noeG_str)
                noeG_frame_list.append(noeG_frame)
                noeG_frame.setVisible(False)
                if blocks_1_obj != None and blocks_1_obj[k]['mg_' +
                                                            str(j)] == True:
                    noeG_frame.setVisible(True)
                main_str.addWidget(noeG_frame)
                noeG_str.setAlignment(QtCore.Qt.AlignCenter)

                if int_lng == 'Russian':
                    napr_lbl.setText("Направление")
                    napr_edit.setToolTip(
                        "Направление, в котором выполняется градуировка")
                    ks_lbl.setText("Количество секторов")
                    ks_edit.setToolTip(
                        "Количество секторов разбиения должно быть не менее одного"
                    )
                elif int_lng == 'English':
                    napr_lbl.setText("Direction")
                    napr_edit.setToolTip(
                        "The direction in which the grading is performed")
                    ks_lbl.setText("Number of sectors")
                    ks_edit.setToolTip(
                        "The number of sectors of the grading must be at least one"
                    )

                j = j + 1
                k = k + 1

                j_list.append(j)

        prs_frame = QtGui.QFrame()
        prs_frame.setLayout(main_str)

        # --------------------------------Кнопка сохранения-------------------------#

        blocks_1_btnSave = QtGui.QPushButton()
        blocks_1_btnSave.setFixedSize(80, 25)
        buttons_hbox = QtGui.QHBoxLayout()
        buttons_hbox.addWidget(blocks_1_btnSave)

        if int_lng == 'Russian':
            blocks_1_btnSave.setText("Записать")
        elif int_lng == 'English':
            blocks_1_btnSave.setText("Write")

# -------------------------Групповой элемент формы--------------------------#

        blocks_1_grid = QtGui.QGridLayout()
        blocks_1_grid.addWidget(main_lbl,
                                0,
                                0,
                                alignment=QtCore.Qt.AlignCenter)
        blocks_1_grid.addWidget(prs_frame,
                                1,
                                0,
                                alignment=QtCore.Qt.AlignCenter)
        blocks_1_grid.addLayout(buttons_hbox,
                                2,
                                0,
                                alignment=QtCore.Qt.AlignCenter)
        blocks_1_grid.setRowStretch(3, 6)
        blocks_1_group = QtGui.QGroupBox()
        blocks_1_group.setLayout(blocks_1_grid)

        return blocks_1_group, blocks_1_btnSave, obj, vrs_edit_list, mg_edit_list, mg_lbl_list, napr_lbl_list, napr_edit_list, ks_lbl_list, ks_edit_list, noeG_frame_list, j_list, v_1_obsh_list, v_2_obsh_list
Ejemplo n.º 8
0
 def limitText(self):
     reg = "[a-z0-9]{5}"
     regEx = QtCore.QRegExp(reg)
     validator = QtGui.QRegExpValidator(regEx)
     return validator
Ejemplo n.º 9
0
 def fullNum(self):
     reg = "[0-9]{8}"
     regEx = QtCore.QRegExp(reg)
     validator = QtGui.QRegExpValidator(regEx)
     return validator
Ejemplo n.º 10
0
    def __init__(self):
        qg.QDialog.__init__(self)
        self.setWindowTitle("Main UI")
        self.setWindowFlags(qc.Qt.WindowStaysOnTopHint)
        self.setFixedHeight(400)
        self.setFixedWidth(450)

        self.setLayout(qg.QVBoxLayout())
        self.layout().setAlignment(qc.Qt.AlignTop)

        rename_widget = qg.QWidget()
        rename_widget.setLayout(qg.QVBoxLayout())
        rename_widget.setContentsMargins(2, 0, 2, 0)
        rename_widget.layout().setSpacing(10)

        name_layout = qg.QHBoxLayout()

        line_splitter = _Splitter('RENAME')
        rename_widget.layout().addWidget(line_splitter)

        name_layout.addWidget(qg.QLabel('New Name:'))
        self.name_field = qg.QLineEdit()
        reg_ex = qc.QRegExp("^(?!^_)[a-zA-Z_]+")
        text_validator = qg.QRegExpValidator(reg_ex, self.name_field)
        self.name_field.setValidator(text_validator)
        name_layout.addWidget(self.name_field)
        rename_widget.layout().addLayout(name_layout)

        rename_widget.layout().addLayout(_LineLayout())

        name_method_layout = qg.QHBoxLayout()
        name_method_layout.addWidget(qg.QLabel('Multiples Naming Method:'))
        self.combo_box = qg.QComboBox()
        self.combo_box.addItems(['Numbers (0-9)', 'Letters(a-z)'])
        self.combo_box.setFixedWidth(100)
        name_method_layout.addWidget(self.combo_box)
        rename_widget.layout().addLayout(name_method_layout)

        option_layout = qg.QHBoxLayout()
        self.padding_lb = qg.QLabel('No. Padding:')
        self.spin_box = qg.QSpinBox()
        self.spin_box.setRange(0, 10)
        self.spin_box.setFixedWidth(40)
        self.lower_btn = qg.QRadioButton('Lowercase')
        self.upper_btn = qg.QRadioButton('Uppercase')
        self.lower_btn.setVisible(False)
        self.upper_btn.setVisible(False)
        self.lower_btn.setChecked(True)
        spacer_item = qg.QSpacerItem(5, 5, qg.QSizePolicy.Expanding)
        option_layout.addWidget(self.padding_lb)
        option_layout.addWidget(self.lower_btn)
        option_layout.addSpacerItem(spacer_item)
        option_layout.addWidget(self.spin_box)
        option_layout.addWidget(self.upper_btn)
        rename_widget.layout().addLayout(option_layout)

        rename_widget.layout().addLayout(_LineLayout())

        pre_suf_layout = qg.QHBoxLayout()
        self.pre_check = qg.QCheckBox('Prefix:')
        self.pre_text = qg.QLineEdit()
        self.pre_text.setValidator(text_validator)
        self.pre_text.setEnabled(False)
        self.suf_check = qg.QCheckBox('Suffix:')
        self.suf_text = qg.QLineEdit()
        self.suf_text.setValidator(text_validator)
        self.suf_text.setEnabled(False)
        pre_suf_layout.addWidget(self.pre_check)
        pre_suf_layout.addWidget(self.pre_text)
        line = qg.QFrame()
        line.setFrameStyle(qg.QFrame.VLine)
        line.setFixedWidth(30)
        pre_suf_layout.addWidget(line)
        pre_suf_layout.addWidget(self.suf_check)
        pre_suf_layout.addWidget(self.suf_text)
        rename_widget.layout().addLayout(pre_suf_layout)

        example_layout = qg.QHBoxLayout()
        self.example_lb = qg.QLabel('e.g.')
        self.example_btn = qg.QPushButton('Rename')
        self.example_btn.setFixedWidth(100)
        example_layout.addWidget(self.example_lb)
        example_layout.addWidget(self.example_btn)
        rename_widget.layout().addLayout(example_layout)

        self.layout().addWidget(rename_widget)

        # ------------------------------ Connections ---------------------------------
        self.combo_box.currentIndexChanged.connect(self._ChangeVisibility)

        self.pre_check.stateChanged.connect(self.pre_text.setEnabled)
        self.suf_check.stateChanged.connect(self.suf_text.setEnabled)

        self.name_field.textChanged.connect(self._update_label)
        self.spin_box.valueChanged.connect(self._update_label)
        self.lower_btn.clicked.connect(self._update_label)
        self.upper_btn.clicked.connect(self._update_label)
        self.pre_text.textChanged.connect(self._update_label)
        self.suf_text.textChanged.connect(self._update_label)

        self.example_btn.clicked.connect(self._to_world)
Ejemplo n.º 11
0
 def addRule(self, pattern, style):
     """Add a rule pattern with given style."""
     self.rules.append((QtCore.QRegExp(pattern), self.styles[style]))
Ejemplo n.º 12
0
    def __init__(self,
                 parent=None,
                 str_run_number='0000',
                 str_run_type='Type N/A',
                 comment=''):

        self.t0_sec = time()

        QtGui.QWidget.__init__(self, parent)

        self.setGeometry(100, 100, 600, 35)
        self.setWindowTitle('GUI Dark Run Item')
        #try : self.setWindowIcon(cp.icon_help)
        #except : pass
        self.setFrame()

        #self.list_of_runs   = None
        self.parent = parent

        self.str_run_number = str_run_number  # cp.str_run_number
        self.str_run_type = str_run_type  # cp.str_run_number
        self.str_run_from = str_run_number  # cp.str_run_from
        self.str_run_to = 'end'  # cp.str_run_to
        self.comment = comment
        self.calib_dir = cp.calib_dir
        self.det_name = cp.det_name
        self.dict_bjpeds = cp.dict_bjpeds

        self.create_or_use_butch_object()

        self.lab_run = QtGui.QLabel('Run')
        self.lab_from = QtGui.QLabel('valid from')
        self.lab_to = QtGui.QLabel('to')

        #self.lab_rnum = QtGui.QPushButton( self.str_run_number )
        self.lab_rnum = QtGui.QLabel(self.str_run_number)
        self.lab_type = QtGui.QLabel(self.str_run_type + ': ' + comment)
        self.but_go = QtGui.QPushButton('Go')
        self.but_depl = QtGui.QPushButton('Deploy')
        self.edi_from = QtGui.QLineEdit(self.str_run_from)
        self.edi_to = QtGui.QLineEdit(self.str_run_to)

        #self.but_stop.setVisible(False)

        self.edi_from.setValidator(QtGui.QIntValidator(0, 9999, self))
        self.edi_to.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp("[0-9]\\d{0,3}|end$"), self))

        self.hbox = QtGui.QHBoxLayout()
        self.hbox.addWidget(self.lab_run)
        self.hbox.addWidget(self.lab_rnum)
        #self.hbox.addStretch(1)
        self.hbox.addWidget(self.lab_from)
        self.hbox.addWidget(self.edi_from)
        self.hbox.addWidget(self.lab_to)
        self.hbox.addWidget(self.edi_to)
        #self.hbox.addSpacing(150)
        self.hbox.addStretch(1)
        self.hbox.addWidget(self.but_go)
        self.hbox.addWidget(self.but_depl)
        self.hbox.addStretch(1)
        self.hbox.addWidget(self.lab_type)
        #self.hbox.addWidget(self.but_stop)

        self.setLayout(self.hbox)

        self.connect(self.but_go, QtCore.SIGNAL('clicked()'), self.onButGo)
        self.connect(self.but_depl, QtCore.SIGNAL('clicked()'),
                     self.onButDeploy)
        self.connect(self.edi_from, QtCore.SIGNAL('editingFinished()'),
                     self.onEdiFrom)
        self.connect(self.edi_to, QtCore.SIGNAL('editingFinished()'),
                     self.onEdiTo)

        self.showToolTips()

        self.setStatusMessage()
        self.setFieldsEnabled(cp.det_name.value() != '')
Ejemplo n.º 13
0
	def out_frame_func(int_lng, prj_path, mesh_name_txt, pd_2, blocks_visible): 
		blocks_2_obj = None
		
		#----------------Если файл blocks_2.pkl существует, получаем данные из него для вывода в форму---------------#
		
		if blocks_visible == True:	
			blocks_2_path_file = prj_path + '/' + mesh_name_txt + '_' + pd_2 + '/' + 'blocks_2.pkl'
			if os.path.exists(blocks_2_path_file):
		
				input = open(blocks_2_path_file, 'rb')
				blocks_2_obj = pickle.load(input)
				input.close()
		
		main_lbl = QtGui.QLabel()
		
		if int_lng == 'Russian':
			main_lbl.setText("Дополнительное описание блоков")
		elif int_lng == 'English':
			main_lbl.setText("Additional block description")
			
		#---------------Формируем внешний вид формы для файла blocks_2.pkl на основе данных файла blocks_1.pkl-------------#
		
		blocks_1_path_file = prj_path + '/' + mesh_name_txt + '_' + pd_2 + '/' + 'blocks_1.pkl'
		if os.path.exists(blocks_1_path_file):
		
			input = open(blocks_1_path_file, 'rb')
			obj_list = pickle.load(input)
			input.close()
			
			srya_list = []
			mg_list = []
			napr_list = []
			ks_list = []
			
			blocks_2_grid = QtGui.QGridLayout()

			sg_eg_obsh_list = []
			
			grad_type = []
			
			i = 1
			h = 0
			nbl = 1
			
			q = 1
			for el in obj_list:
				
				srya_list.append(el['srya_' + str(q)])
				mg_list.append(el['mg_' + str(q)])
				napr_list.append(el['napr_' + str(q)])
				ks_list.append(el['ks_' + str(q)])
				
				blocks_lbl = QtGui.QLabel()
				blocks_2_grid.addWidget(blocks_lbl, i, 0, alignment=QtCore.Qt.AlignCenter)
				
				validator = QtGui.QRegExpValidator(QtCore.QRegExp("\\d*\\.\\d+"))
			
				el_srya_lbl = QtGui.QLabel(srya_list[h])
				
				if int_lng == 'Russian':
					blocks_lbl.setText("Мультиградуировка для блока " + str(nbl))
				elif int_lng == 'English':
					blocks_lbl.setText("Multigrading for the block " + str(nbl))
				###########################################################################
				if srya_list[h] == "simpleGrading" and mg_list[h] != True:
					
					n = 1
					p = 0
					sg_list = []
					nosg_str = QtGui.QHBoxLayout()
					while n <= 3:

						sg_edit = QtGui.QLineEdit()
						if n == 1:
							if int_lng == 'Russian':
								sg_edit.setToolTip("Степень расширения для направления x1 - неотрицательное число")
							elif int_lng == 'English':
								sg_edit.setToolTip("Degree of expansion for x1 direction - nonnegative number")
						elif n == 2:
							if int_lng == 'Russian':
								sg_edit.setToolTip("Степень расширения для направления x2 - неотрицательное число")
							elif int_lng == 'English':
								sg_edit.setToolTip("Degree of expansion for x2 direction - nonnegative number")
						elif n == 3:
							if int_lng == 'Russian':
								sg_edit.setToolTip("Степень расширения для направления x3 - неотрицательное число")
							elif int_lng == 'English':
								sg_edit.setToolTip("Degree of expansion for x3 direction - nonnegative number")
						if blocks_2_obj != None:
							sg_edit.setText(blocks_2_obj[h]['simpleGrading'][p])
						sg_edit.setFixedSize(30, 21)
						
						sg_edit.setValidator(validator)
						nosg_str.insertWidget(n, sg_edit)
						sg_list.append(sg_edit)
						n = n + 1
						p = p + 1

					sg_grid = QtGui.QGridLayout()
					sg_lbl = QtGui.QLabel(srya_list[h])
					sg_grid.addWidget(sg_lbl, 0, 0)
					sg_grid.addLayout(nosg_str, 0, 1)
					
					sg_frame = QtGui.QFrame()
					sg_frame.setLayout(sg_grid)
					
					grad_type.append("simpleGrading")
					sg_eg_obsh_list.append(sg_list)
					
				###########################################################################	
				if srya_list[h] == "simpleGrading" and mg_list[h] == True:
					if napr_list[h] == 'x':
						
						sg_mg_grid = QtGui.QGridLayout()
						sg_mg_lbl = QtGui.QLabel(srya_list[h])
						sg_mg_grid.addWidget(sg_mg_lbl, 0, 0)
						
						k = 0
						u = 1
						
						x_list = []
						sg_list_lvl = []
						while u <= ks_list[h]:
							l = 1
							x_str = QtGui.QHBoxLayout()
							sect_list = []
							p = 0
							while l <= 3:
								x_edit = QtGui.QLineEdit()
								if l == 1:
									if int_lng == 'Russian':
										x_edit.setToolTip("Доля сектора " + str(u) + " от длины блока для направления 'x' - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										x_edit.setToolTip("Share of the sector " + str(u) + " from the length of the block for the 'x' direction - in percent, fractions or absolute lengths")
								elif l == 2:
									if int_lng == 'Russian':
										x_edit.setToolTip("Доля ячеек в секторе " + str(u) + " - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										x_edit.setToolTip("The share of cells in the sector " + str(u) + " - in percent, fractions or absolute lengths")
								elif l == 3:
									if int_lng == 'Russian':
										x_edit.setToolTip("Расширение для сектора " + str(u) + " для направления 'x' - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										x_edit.setToolTip("Expansion for the sector " + str(u) + " for the 'x' direction - in percentages, fractions or absolute lengths")
								
								if blocks_2_obj != None:
									x_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][0]['x'][k]['sekt_' + str(u)][p])
								x_edit.setFixedSize(30, 21)
								x_edit.setValidator(validator)
								x_str.insertWidget(l, x_edit)
								sect_list.append(x_edit)
								l = l + 1
								p = p + 1
								
							x_list.append(sect_list)
							
							x_lbl = QtGui.QLabel()
							if int_lng == 'Russian':
								x_lbl.setText("// доля сектора в %, доля ячеек в %, расширение //" + " - сектор " + str(u) + " направления x")
							elif int_lng == 'English':
								x_lbl.setText("// sector share in %, percentage of cells in %, extension //" + " - sector " + str(u) + " direction x")
							
							
							sg_mg_grid.addLayout(x_str, k, 1)
							sg_mg_grid.addWidget(x_lbl, k, 2)
							
							k = k + 1
							u = u + 1
							
						y_edit = QtGui.QLineEdit()
						if blocks_2_obj != None:
							y_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][1]['y'])
						y_edit.setFixedSize(30, 21)
						y_edit.setValidator(validator)
						y_lbl = QtGui.QLabel()
						sg_mg_grid.addWidget(y_edit, k + 1, 1)
						sg_mg_grid.addWidget(y_lbl, k + 1, 2)
						
						
						z_edit = QtGui.QLineEdit()
						if blocks_2_obj != None:
							z_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][2]['z'])
						z_edit.setFixedSize(30, 21)
						z_edit.setValidator(validator)
						z_lbl = QtGui.QLabel()
						sg_mg_grid.addWidget(z_edit, k + 2, 1)
						sg_mg_grid.addWidget(z_lbl, k + 2, 2)
						
						
						if int_lng == 'Russian':
							y_edit.setToolTip("Степень расширения для направления 'y' - в процентах, долях или абсолютных длинах")
							y_lbl.setText("Cтепень расширения в направлении 'y'")
							z_edit.setToolTip("Степень расширения для направления 'z' - в процентах, долях или абсолютных длинах")
							z_lbl.setText("Cтепень расширения в направлении 'z'")
						elif int_lng == 'English':
							y_edit.setToolTip("The degree of expansion for the 'y' direction is in percentages, fractions or absolute lengths")
							y_lbl.setText("The degree of expansion in the 'y' direction")
							z_edit.setToolTip("The degree of expansion for the 'z' direction is in percentages, fractions or absolute lengths")
							z_lbl.setText("The degree of expansion in the 'z' direction")
						sg_list_lvl.append(x_list)
						sg_list_lvl.append(y_edit)
						sg_list_lvl.append(z_edit)
					#------------------------------------------	
					if napr_list[h] == 'y':
						sg_mg_grid = QtGui.QGridLayout()
						sg_mg_lbl = QtGui.QLabel(srya_list[h])
						sg_mg_grid.addWidget(sg_mg_lbl, 0, 0)
						
						x_edit = QtGui.QLineEdit()
						if blocks_2_obj != None:
							x_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][0]['x'])
						x_edit.setFixedSize(30, 21)
						x_edit.setValidator(validator)
						x_lbl = QtGui.QLabel()
						sg_mg_grid.addWidget(x_edit, 0, 1)
						sg_mg_grid.addWidget(x_lbl, 0, 2)
						
						k = 1
						u = 1
						o = 0
						
						y_list = []
						sg_list_lvl = []
						#print(ks_list[h])
						while u <= ks_list[h]:
							l = 1
							y_str = QtGui.QHBoxLayout()
							sect_list = []
							p = 0
							while l <= 3:
								y_edit = QtGui.QLineEdit()
								if l == 1:
									if int_lng == 'Russian':
										y_edit.setToolTip("Доля сектора " + str(u) + " от длины блока для направления 'y' - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										y_edit.setToolTip("Share of the sector " + str(u) + " from the length of the block for the 'y' direction - in percentages, fractions or absolute lengths")

								elif l == 2:
									if int_lng == 'Russian':
										y_edit.setToolTip("Доля ячеек в секторе " + str(u) + " - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										y_edit.setToolTip("The share of cells in the sector " + str(u) + " - in percentages, fractions or absolute lengths")

								elif l == 3:
									if int_lng == 'Russian':
										y_edit.setToolTip("Расширение для сектора " + str(u) + " для направления 'y' - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										y_edit.setToolTip("Expansion for the sector " + str(u) + " for the 'y' direction - in percentages, fractions or absolute lengths")

								if blocks_2_obj != None:
									y_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][1]['y'][o]['sekt_' + str(u)][p])
								y_edit.setFixedSize(30, 21)
								y_edit.setValidator(validator)
								y_str.insertWidget(l, y_edit)
								sect_list.append(y_edit)
								l = l + 1
								p = p + 1
								
							y_list.append(sect_list)
								
							y_lbl = QtGui.QLabel()
							if int_lng == 'Russian':
								y_lbl.setText("// доля сектора в %, доля ячеек в %, расширение //" + " - сектор " + str(u) + " направления 'y'")
							elif int_lng == 'English':
								y_lbl.setText("// sector share in %, percentage of cells in%, extension //" + " - sector " + str(u) + " 'y' direction")
							
							sg_mg_grid.addLayout(y_str, k, 1)
							sg_mg_grid.addWidget(y_lbl, k, 2)
							
							k = k + 1
							u = u + 1
							o = o + 1
						
						z_edit = QtGui.QLineEdit()
						if blocks_2_obj != None:
							z_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][2]['z'])
						z_edit.setFixedSize(30, 21)
						z_edit.setValidator(validator)
						z_lbl = QtGui.QLabel()
						sg_mg_grid.addWidget(z_edit, k + 1, 1)
						sg_mg_grid.addWidget(z_lbl, k + 1, 2)
						
						sg_list_lvl.append(x_edit)
						sg_list_lvl.append(y_list)
						sg_list_lvl.append(z_edit)
											  
						if int_lng == 'Russian':
							x_edit.setToolTip("Степень расширения для направления 'x' - в процентах, долях или абсолютных длинах")
							x_lbl.setText("Cтепень расширения в направлении 'x'")
							z_edit.setToolTip("Степень расширения для направления 'z' - в процентах, долях или абсолютных длинах")
							z_lbl.setText("Cтепень расширения в направлении 'z'")
						elif int_lng == 'English':
							x_edit.setToolTip("The degree of expansion for the 'x' direction is in percentages, fractions or absolute lengths")
							x_lbl.setText("The degree of expansion in the 'x' direction")
							z_edit.setToolTip("Degree of expansion for the 'z' direction - in percent, fractions or absolute lengths")
							z_lbl.setText("The degree of expansion in the 'z' direction")
					#--------------------------------------------
					if napr_list[h] == 'z':
						sg_mg_grid = QtGui.QGridLayout()
						sg_mg_lbl = QtGui.QLabel(srya_list[h])
						sg_mg_grid.addWidget(sg_mg_lbl, 0, 0)
						
						x_edit = QtGui.QLineEdit()
						if blocks_2_obj != None:
							x_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][0]['x'])
						x_edit.setFixedSize(30, 21)
						x_edit.setValidator(validator)
						x_lbl = QtGui.QLabel()
						sg_mg_grid.addWidget(x_edit, 0, 1)
						sg_mg_grid.addWidget(x_lbl, 0, 2)
						
						y_edit = QtGui.QLineEdit()
						if blocks_2_obj != None:
							y_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][1]['y'])
						y_edit.setFixedSize(30, 21)
						y_edit.setValidator(validator)
						y_lbl = QtGui.QLabel()
						sg_mg_grid.addWidget(y_edit, 1, 1)
						sg_mg_grid.addWidget(y_lbl, 1, 2)
						
						k = 2
						u = 1
	
						z_list = []
						sg_list_lvl = []
						while u <= ks_list[h]:
							l = 1
							z_str = QtGui.QHBoxLayout()
							sect_list = []
							p = 0
							while l <= 3:
								z_edit = QtGui.QLineEdit()
								if l == 1:
									if int_lng == 'Russian':
										z_edit.setToolTip("Доля сектора " + str(u) + " от длины блока для направления 'z' - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										z_edit.setToolTip("Share of the sector " + str(u) + " from the length of the block for the 'z' direction - in percentages, fractions or absolute lengths")	  
								elif l == 2:
									if int_lng == 'Russian':
										z_edit.setToolTip("Доля ячеек в секторе " + str(u) + " - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										z_edit.setToolTip("The share of cells in the sector " + str(u) + " - in percentages, fractions or absolute lengths")
								elif l == 3:
									if int_lng == 'Russian':
										z_edit.setToolTip("Расширение для сектора " + str(u) + " для направления 'z' - в процентах, долях или абсолютных длинах")
									elif int_lng == 'English':
										z_edit.setToolTip("Expansion for the sector " + str(u) + " for the 'z' direction - in percent, fractions or absolute lengths")
								if blocks_2_obj != None:
									z_edit.setText(blocks_2_obj[h]['simpleGrading_mg'][0]['mg_blocks_' + str(nbl)][2]['z'][k]['sekt_' + str(u)][p])
								z_edit.setFixedSize(30, 21)
								z_edit.setValidator(validator)
								z_str.insertWidget(l, z_edit)
								sect_list.append(z_edit)
								l = l + 1
								p = p + 1
								
							z_list.append(sect_list)
								
							z_lbl = QtGui.QLabel()
							if int_lng == 'Russian':
								z_lbl.setText("// доля сектора в %, доля ячеек в %, расширение //" + " - сектор " + str(u) + " направления 'z'")
							if int_lng == 'English':
								z_lbl.setText("// sector share in %, percentage of cells in %, extension //" + " - sector " + str(u) + " 'z' direction")
							
							sg_mg_grid.addLayout(z_str, k, 1)
							sg_mg_grid.addWidget(z_lbl, k, 2)
							
							k = k + 1
							u = u + 1
						
						sg_list_lvl.append(x_edit)
						sg_list_lvl.append(y_edit)
						sg_list_lvl.append(z_list)
						
						if int_lng == 'Russian':
							x_edit.setToolTip("Степень расширения для направления 'x' - в процентах, долях или абсолютных длинах")
							x_lbl.setText("Cтепень расширения в направлении 'x'")
							y_edit.setToolTip("Степень расширения для направления 'y' - в процентах, долях или абсолютных длинах")
							y_lbl.setText("Cтепень расширения в направлении 'y'")
						elif int_lng == 'English':
							x_edit.setToolTip("The degree of expansion for the 'x' direction is in percentages, fractions or absolute lengths")
							x_lbl.setText("The degree of expansion in the 'x' direction")				  
							y_edit.setToolTip("The degree of expansion for the 'y' direction is in percentages, fractions or absolute lengths")
							y_lbl.setText("The degree of expansion in the 'y' direction")				  
					sg_frame = QtGui.QFrame()
					sg_frame.setLayout(sg_mg_grid)
					
					grad_type.append("simpleGrading_mg")
					sg_eg_obsh_list.append(sg_list_lvl)
				###########################################################################	
				if srya_list[h] == "edgeGrading":
					
					n = 1
					p = 0
					eg_list = []
					noegr_str = QtGui.QHBoxLayout()
					while n <= 12:

						eg_edit = QtGui.QLineEdit()
						if int_lng == 'Russian':
							eg_edit.setToolTip("Степень расширения для ребра " + str(n) + " блока - неотрицательное число")
						elif int_lng == 'English':
							eg_edit.setToolTip("The degree of expansion for the edge " + str(n) + " block - nonnegative number")				  
						if blocks_2_obj != None:
							eg_edit.setText(blocks_2_obj[h]['edgeGrading'][p])
						eg_edit.setFixedSize(30, 21)
						eg_edit.setValidator(validator)
						noegr_str.insertWidget(n, eg_edit)
						eg_list.append(eg_edit)
						n = n + 1
						p = p + 1
					
					eg_grid = QtGui.QGridLayout()
					eg_lbl = QtGui.QLabel(srya_list[h])
					eg_grid.addWidget(eg_lbl, 0, 0)
					eg_grid.addLayout(noegr_str, 0, 1)
					
					sg_frame = QtGui.QFrame()
					sg_frame.setLayout(eg_grid)
					
					grad_type.append("edgeGrading")
					sg_eg_obsh_list.append(eg_list)
				
				blocks_2_grid.addWidget(sg_frame, i + 1, 0, alignment=QtCore.Qt.AlignCenter)
				
				i = i + 2
				h = h + 1
				nbl = nbl + 1
				q = q + 1
				
			# -----------------------Кнопка сохранения------------------------#	

			blocks_2_btnSave = QtGui.QPushButton("Записать")
			if int_lng == 'Russian':
				blocks_2_btnSave.setText("Записать")
			elif int_lng == 'English':
				blocks_2_btnSave.setText("Write")							  
			blocks_2_btnSave.setFixedSize(80, 25)
			buttons_hbox = QtGui.QHBoxLayout()
			buttons_hbox.addWidget(blocks_2_btnSave)

			blocks_2_grid.addLayout(buttons_hbox, i + 1, 0, alignment=QtCore.Qt.AlignCenter)
			blocks_2_grid.setRowStretch(i + 2, 6)
			
			# ---------------------Групповой элемент формы--------------------#
			
			blocks_2_group = QtGui.QGroupBox()
			blocks_2_group.setLayout(blocks_2_grid)

		return blocks_2_group, blocks_2_btnSave, obj_list, grad_type, sg_eg_obsh_list
Ejemplo n.º 14
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        
        self.setWindowFlags(QtCore.Qt.Window)
        self.setWindowModality(QtCore.Qt.WindowModal)

        global types_mas
        global mas
        global c_txt_mas
        global un_txt_mas
        global fw_mas
        global frame_mas
        global fixedV
        global unifs_mas
        global val_mas
        global vali_mas
        global un_txt_mas
        global values
        global perem1_mas
        global nv_mas 

#-------------------Обработчики выпадающих списков-----------------------
        def iF_on_change():
            iF_txt = iF_name.currentText()
            if iF_txt == "uniform":
                iF_name.setVisible(True)
                iF_val.setVisible(True)
                iF_frame.setFixedSize(230, 40)
            else:
                iF_val.setVisible(False)
                iF_frame.setFixedSize(170, 40)

        def on_change():
            w = 0
            c_txt_mas = []
            for w in range(len(types_mas)):
                c_txt = types_mas[w].currentText()
                c_txt_mas.append(c_txt)
                w = w + 1

            for h in range(len(c_txt_mas)):
                if c_txt_mas[h] == "fixedValue":
                    unifs_mas[h].setVisible(True)
                else:
                    unifs_mas[h].setVisible(False)
                    vali_mas[h].setVisible(False)

        def on_change_unif():
            e = 0
            un_txt_mas = []
            for e in range(len(unifs_mas)):
                un_txt = unifs_mas[e].currentText()
                un_txt_mas.append(un_txt)
                e = e + 1
            for b in range(len(un_txt_mas)):
                if un_txt_mas[b] == "uniform" and unifs_mas[b].isVisible() == True:
                    vali_mas[b].setVisible(True)
                else:
                    vali_mas[b].setVisible(False)

#--------------------------------Первый блок.Разметка и вывод данных----------------------------------

        p1 = QtGui.QLineEdit()
        p1.setFixedSize(30, 25)
        valid = QtGui.QRegExpValidator(QtCore.QRegExp("[0-9]|-[0-9]"), self)
        p1.setValidator(valid)

        p2 = QtGui.QLineEdit()
        p2.setFixedSize(30, 25)
        p2.setValidator(valid)
        
        p3 = QtGui.QLineEdit()
        p3.setFixedSize(30, 25)
        p3.setValidator(valid)

        p4 = QtGui.QLineEdit()
        p4.setFixedSize(30, 25)
        p4.setValidator(valid)

        p5 = QtGui.QLineEdit()
        p5.setFixedSize(30, 25)
        p5.setValidator(valid)
        
        p6 = QtGui.QLineEdit()
        p6.setFixedSize(30, 25)
        p6.setValidator(valid)
        
        p7 = QtGui.QLineEdit()
        p7.setFixedSize(30, 25)
        p7.setValidator(valid)

        dim_lbl = QtGui.QLabel("dimensions: ")
        dim_grid = QtGui.QGridLayout()

        dim_grid.addWidget(dim_lbl, 0, 1)
        dim_grid.addWidget(p1, 0, 2)
        dim_grid.addWidget(p2, 0, 3)
        dim_grid.addWidget(p3, 0, 4)
        dim_grid.addWidget(p4, 0, 5)
        dim_grid.addWidget(p5, 0, 6)
        dim_grid.addWidget(p6, 0, 7)
        dim_grid.addWidget(p7, 0, 8)

        dim_frame = QtGui.QFrame()
        dim_frame.setFixedSize(315, 40)
        dim_frame.setStyleSheet(open("./styles/properties_form_style.qss","r").read())
        dim_frame.setLayout(dim_grid)
        dim_hbox = QtGui.QHBoxLayout()
        dim_hbox.addWidget(dim_frame)

        full_dir = parent.d
        file = open(full_dir+"/0/T", 'r') 
        data = file.read()
        file.close()

        dim_reg = re.compile(r"(?<=[\[])\S*\s\S*\s\S*\s\S*\s\S*\s\S*\s\S*(?=[\]])")
        dim_mas = dim_reg.findall(data)
        dim_div = dim_mas[0].split(" ")
        p1.setText(dim_div[0])
        p2.setText(dim_div[1])
        p3.setText(dim_div[2])
        p4.setText(dim_div[3])
        p5.setText(dim_div[4])
        p6.setText(dim_div[5])
        p7.setText(dim_div[6])

#--------------------------------Второй блок.Разметка и вывод данных----------------------------------
        
        iF_lbl = QtGui.QLabel("internalField: ")
            
        iF_name = QtGui.QComboBox()
        iF_name.setFixedSize(80, 25)
        iF_list = ["nonuniform", "uniform"]
        iF_name.addItems(iF_list)
        iF_name.activated.connect(iF_on_change)

        iF_val = QtGui.QLineEdit()
        iF_val.setFixedSize(50, 25)
        val = QtGui.QDoubleValidator(0.0, 999.0, 2, self)
        iF_val.setValidator(val)
        iF_val.setVisible(False)

        iF_grid = QtGui.QGridLayout()
        iF_grid.addWidget(iF_lbl, 0, 0, alignment=QtCore.Qt.AlignCenter)
        iF_grid.addWidget(iF_name, 0, 1, alignment=QtCore.Qt.AlignLeft)
        iF_grid.addWidget(iF_val, 0, 2, alignment=QtCore.Qt.AlignCenter)

        iF_frame = QtGui.QFrame()
        iF_frame.setFixedSize(230, 40)
        iF_frame.setStyleSheet(open("./styles/properties_form_style.qss","r").read())
        iF_frame.setLayout(iF_grid)
        iF_hbox = QtGui.QHBoxLayout()
        iF_hbox.addWidget(iF_frame)

        file = open(full_dir+"/0/T", 'r') 
        data = file.read()
        file.close()

        iF_reg = re.compile(r"internalField\s*\S*\s\S*(?=[;])|internalField\s*\S*(?=[;])")
        iF_mas = iF_reg.findall(data)
        iF_div = iF_mas[0].split("   ")
        iF_part = iF_div[1].split(" ")

        iF_edit_mas = iF_name.count()   
        for bvc in range(iF_edit_mas):
            if iF_name.itemText(bvc) == iF_part[0]:
                iF_name.setCurrentIndex(bvc)

        if iF_part[0] == "uniform":
            iF_val.setVisible(True)
            iF_val.setText(iF_part[1])

#--------------------------------Третий блок.Разметка и вывод данных----------------------------------

        file = open(full_dir+"/0/T", 'r') 
        data = file.read()
        file.close()

        bF_lbl = QtGui.QLabel("boundaryField")
        str_grid = QtGui.QGridLayout()
   
        str_frame = QtGui.QFrame()
        str_frame.setStyleSheet(open("./styles/properties_form_style.qss","r").read())
        str_frame.setFrameShape(QtGui.QFrame.Panel)
        str_frame.setFrameShadow(QtGui.QFrame.Sunken)
        str_frame.setLayout(str_grid)
        
        str_vbox = QtGui.QVBoxLayout() 
        str_vbox.addWidget(str_frame)

        struct_reg = re.compile(r"\S*\n\s*\{\s*\n\s*type")
        struct_mas = struct_reg.findall(data)

        type_reg = re.compile(r"type\s*\S*(?=[;])")
        type_mas = type_reg.findall(data)
      
        m = 0
        mas_type = []
        for variant in range(len(type_mas)):
            type_div = type_mas[m].split("            ")
            m = m + 1
            mas_type.append(type_div[1])

        i = 0
        mas = []
        for elem in range(len(struct_mas)):
            div = struct_mas[i].split("\n")
            i = i + 1
            mas.append(div[0])

        file = open(full_dir+"/0/T", 'r') 
        data = file.read()
        file.close()
        
        hr_reg = re.compile(r"\n\s*\S*\n\s*\{\n\s*type\s*fixedValue;\n\s*value\s*\S*\s\S*\n\s*\}|\n\s*\S*\n\s*\{\n\s*type\s*\S*\n\s*\}|\n\s*\S*\n\s*\{\n\s*type\s*fixedValue;\n\s*value\s*\S*\n\s*\}")
        hr_mas = hr_reg.findall(data)

        perem1_mas = []
        for cvde in range(len(hr_mas)):
            unit_reg = re.compile(r"value\s*\w*")
            lre_mas = unit_reg.findall(hr_mas[cvde])
            if len(lre_mas) == 1:
                dal_div = lre_mas[0].split("           ")
                if dal_div[1] == "uniform" or dal_div[1] == "nonuniform":
                    perem1_mas.append(dal_div[1])
            else:
                perem1_mas.append("none")

        perem2_mas = []
        for cvdm in range(len(hr_mas)):
            uniform_reg = re.compile(r"\suniform\s*\S*(?=[;])")
            mre_mas = uniform_reg.findall(hr_mas[cvdm])
            if len(mre_mas) == 1:
                mal_div = mre_mas[0].split(" ")
                perem2_mas.append(mal_div[2])
            else:
                perem2_mas.append("none")    

        n = 0
        types_mas = []
        grids_mas = []
        frame_mas = []
        unifs_mas = []
        vali_mas = []
        un_mas = []
        uv_mas = []
        for j in range(len(mas)):
            
            type_lbl = QtGui.QLabel("type: ")
            
            type_name = QtGui.QComboBox()
            type_name.setFixedSize(100, 25)
            type_list = ["fixedValue", "empty", "zeroGradient", "symmetryPlane"]
            type_name.addItems(type_list)

            unif_name = QtGui.QComboBox()
            unif_name.setFixedSize(80, 25)
            unif_list = ["nonuniform", "uniform"]
            unif_name.addItems(unif_list)
            unif_name.setVisible(False)

            unif_val = QtGui.QLineEdit()
            unif_val.setFixedSize(50, 25)
            validator = QtGui.QDoubleValidator(0.0, 999.0, 2, self)
            unif_val.setValidator(validator)
            unif_val.setVisible(False)
            
            type_grid = QtGui.QGridLayout()
            type_grid.addWidget(type_lbl, 0, 0, alignment=QtCore.Qt.AlignCenter)
            type_grid.addWidget(type_name, 0, 1, alignment=QtCore.Qt.AlignLeft)
            type_grid.addWidget(unif_name, 0, 2, alignment=QtCore.Qt.AlignCenter)
            type_grid.addWidget(unif_val, 0, 3, alignment=QtCore.Qt.AlignCenter)

            type_frame = QtGui.QFrame()
            type_frame.setFixedSize(280, 40)
            type_frame.setStyleSheet(open("./styles/properties_form_style.qss","r").read())
            type_frame.setLayout(type_grid)
            type_hbox = QtGui.QHBoxLayout()
            type_hbox.addWidget(type_frame)

            str_lbl = QtGui.QLabel(mas[j])
            str_grid.addWidget(str_lbl, j, 0, alignment=QtCore.Qt.AlignCenter)
            str_grid.addLayout(type_hbox, j, 1)
            
            for r in range(len(type_list)):
                if type_list[r] == mas_type[j]:
                    type_name.setCurrentIndex(r)
                    if type_name.currentText() == "fixedValue":
                        unif_name.setVisible(True)

                        for x in range(len(unif_list)):
                            if unif_list[x] == perem1_mas[j]:
                                unif_name.setCurrentIndex(x)
                                if unif_name.currentText() == "uniform":
                                    unif_val.setVisible(True)
                                    unif_val.setText(perem2_mas[j])
                        
            types_mas.append(type_name)
            frame_mas.append(type_frame)

            unifs_mas.append(unif_name)
            vali_mas.append(unif_val)
        
            types_mas[j].activated.connect(on_change)
            unifs_mas[j].activated.connect(on_change_unif)


#------------------------------------------------------------------------

        def on_btnCancel_clicked():
            self.clear_label = QtGui.QLabel()
            parent.ffw.setTitleBarWidget(self.clear_label)
            self.close()

        def on_btnSave_clicked():
            #----------Первый блок.Запись данных----------
            file = open(full_dir+"/0/T", 'r')
            data = file.read()
            file.close()

            p1_txt = p1.text()
            p2_txt = p2.text()
            p3_txt = p3.text()
            p4_txt = p4.text()
            p5_txt = p5.text()
            p6_txt = p6.text()
            p7_txt = p7.text()

            dim_reg = re.compile(r"(?<=[\[])\S*\s\S*\s\S*\s\S*\s\S*\s\S*\s\S*(?=[\]])")
            dim_mas = dim_reg.findall(data)
            dim_txt_add = p1_txt+" "+p2_txt+" "+p3_txt+" "+p4_txt+" "+p5_txt+" "+p6_txt+" "+p7_txt
            data = data.replace(dim_mas[0], dim_txt_add)

            file = open(full_dir+"/0/T", 'w')  
            file.write(data)
            file.close()

            #----------Второй блок.Запись данных----------

            file = open(full_dir+"/0/T", 'r') 
            data = file.read()
            file.close()

            iF_reg = re.compile(r"internalField\s*\S*\s\S*(?=[;])|internalField\s*\S*(?=[;])")
            iF_mas = iF_reg.findall(data)

            if iF_name.currentText() == "uniform":
                iF_txt_add = "internalField"+"   "+iF_name.currentText()+" "+iF_val.text()
            else:
                iF_txt_add = "internalField"+"   "+iF_name.currentText()

            data = data.replace(iF_mas[0], iF_txt_add)

            file = open(full_dir+"/0/T", 'w')  
            file.write(data)
            file.close()

            #----------Третий блок.Запись данных----------
            
            file = open(full_dir+"/0/T", 'r') 
            data = file.read()
            file.close()

            u = 0
            new_tn_mas = []
            for w in range(len(types_mas)):
                new_tn_mas.append(types_mas[w].currentText())
                u = u + 1

            for s in range(len(mas)):
                if new_tn_mas[s] == "fixedValue":
                    type_reg = re.compile(r"\n\s*"+mas[s]+r"\n\s*\{\n\s*type\s*fixedValue;\n\s*value\s*\S*\s\S*\n\s*\}|\n\s*"+mas[s]+r"\n\s*\{\n\s*type\s*fixedValue;\n\s*value\s*\S*\n\s*\}|\n\s*"+mas[s]+r"\n\s*\{\n\s*type\s*\S*\n\s*\}")
                    type_mas = type_reg.findall(data)
                    tn_txt_add = "\n"+"    "+mas[s]+"\n"+"    "+"{"+"\n"+"  "+"      "+"type            "+new_tn_mas[s]+";"+"\n"+"  "+"      "+"value"+"           "+"meaning"+"\n"+"    "+"}"
                    data = data.replace(type_mas[0], tn_txt_add)
                else:
                    dr_reg = re.compile(r"\n\s*"+mas[s]+r"\n\s*\{\n\s*type\s*fixedValue;\n\s*value\s*\S*\s\S*\n\s*\}|\n\s*"+mas[s]+r"\n\s*\{\n\s*type\s*fixedValue;\n\s*value\s*\S*\n\s*\}|\n\s*"+mas[s]+r"\n\s*\{\n\s*type\s*\S*\n\s*\}")
                    dr_mas = dr_reg.findall(data)
                    dr_txt_add = "\n"+"    "+mas[s]+"\n"+"    "+"{"+"\n"+"  "+"      "+"type            "+new_tn_mas[s]+";"+"\n"+"    "+"}"
                    data = data.replace(dr_mas[0], dr_txt_add)

                file = open(full_dir+"/0/T", 'w')  
                file.write(data)
                file.close()
                    
            z = 0
            un_vals = []
            for z in range(len(unifs_mas)):
                if unifs_mas[z].isVisible() == True:
                    un_vals.append(unifs_mas[z].currentText())
                    z = z + 1

            lk = 0
            uv_vals = []
            for lk in range(len(vali_mas)):
                if vali_mas[lk].isVisible() == True:
                    uv_vals.append(vali_mas[lk].text())
                    lk = lk + 1
  

            file = open(full_dir+"/0/T", 'r') 
            data = file.read()
            file.close()

            vals_reg = re.compile(r"value\s*meaning")
            vals_mas = vals_reg.findall(data)
  
            for v in range(len(un_vals)):
                if un_vals[v] == "uniform":
                    val1_txt_add = "value"+"           "+un_vals[v]+";"
                    data = data.replace(vals_mas[0], val1_txt_add, 1)
                else:
                    val2_txt_add = "value"+"           "+un_vals[v]+";"
                    data = data.replace(vals_mas[0], val2_txt_add, 1)

                file = open(full_dir+"/0/T", 'w')  
                file.write(data)
                file.close()
                
            file = open(full_dir+"/0/T", 'r') 
            data = file.read()
            file.close()

            val_un_reg = re.compile(r"value\s*uniform;")
            val_un_mas = val_un_reg.findall(data)
            for xr in range(len(uv_vals)):
                val_un_txt_add = "value"+"           "+"uniform"+" "+uv_vals[xr]+";"
                data = data.replace(val_un_mas[0], val_un_txt_add, 1)

                file = open(full_dir+"/0/T", 'w')  
                file.write(data)
                file.close()

            parent.item = QtGui.QListWidgetItem("Сохранен файл: T", parent.listWidget)
            parent.color = QtGui.QColor("green")
            parent.item.setTextColor(parent.color)
            parent.listWidget.addItem(parent.item)

  # ---------------------Кнопки-----------------------

        btnSave = QtGui.QPushButton("Сохранить")
        btnSave.setFixedSize(70, 25)
        btnSave.clicked.connect(on_btnSave_clicked)
        btnCancel = QtGui.QPushButton("Отмена")
        btnCancel.setFixedSize(70, 25)
        btnCancel.clicked.connect(on_btnCancel_clicked)
        buttons_hbox = QtGui.QHBoxLayout()
        buttons_hbox.addWidget(btnSave)
        buttons_hbox.addWidget(btnCancel)

# -------------------------Фрейм формы---------------------------

        bound_grid = QtGui.QGridLayout()
        bound_grid.addLayout(dim_hbox, 0, 0, alignment=QtCore.Qt.AlignCenter)
        bound_grid.addLayout(iF_hbox, 1, 0, alignment=QtCore.Qt.AlignCenter)
        bound_grid.addWidget(bF_lbl, 2, 0, alignment=QtCore.Qt.AlignCenter)
        bound_grid.addLayout(str_vbox, 3, 0, alignment=QtCore.Qt.AlignCenter)
        bound_grid.addLayout(buttons_hbox, 4, 0, alignment=QtCore.Qt.AlignCenter)
        bound_frame = QtGui.QFrame()
        bound_frame.setStyleSheet(open("./styles/properties_form_style.qss","r").read())
        bound_frame.setLayout(bound_grid)
        bound_vbox = QtGui.QVBoxLayout() 
        bound_vbox.addWidget(bound_frame)

# ---------------------Размещение на форме всех компонентов-------------------------

        form_1 = QtGui.QFormLayout()
        form_1.addRow(bound_vbox)
        self.setLayout(form_1)
Ejemplo n.º 15
0
    def __init__(self, main, parent):
        QtGui.QDialog.__init__(self, parent)
        load_ui(self, 'dialogs/midi_import.ui')
        self.main = main

        self.import_btn = QtGui.QPushButton('Import to library')
        self.import_btn.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogSaveButton))
        self.buttonBox.addButton(self.import_btn,
                                 QtGui.QDialogButtonBox.ActionRole)
        self.import_btn.clicked.connect(self.import_sounds)

        self.export_state = False
        self.midi_state = False

        self.dump_btn = QtGui.QPushButton('Dump all')
        self.dump_btn.setEnabled(False)
        self.dump_btn.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_ArrowRight))
        self.buttonBox.addButton(self.dump_btn,
                                 QtGui.QDialogButtonBox.ActionRole)
        self.dump_btn.clicked.connect(self.dump_sounds)

        self.splitter.setCollapsible(1, True)

        self.sound_list = []
        self.export_list = []

        self.model = self.sounds_table.model()
        self.sounds_table.setColumnCount(len(self.sound_headers))
        self.sounds_table.setHorizontalHeaderLabels(self.sound_headers)
        self.sounds_table.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.ResizeToContents)
        self.sounds_table.horizontalHeader().setResizeMode(
            3, QtGui.QHeaderView.Stretch)
        self.sounds_table.verticalHeader().setVisible(False)
        self.sounds_table.horizontalHeader().setVisible(True)
        self.sounds_table.verticalHeader().setResizeMode(
            QtGui.QHeaderView.ResizeToContents)
        self.bankmap_combo.addItems([uppercase[b] for b in range(8)])
        self.bankmap_btn.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogApplyButton))

        self.destination_group.setId(self.sound_buffer_radio, 0)
        self.destination_group.setId(self.multi_buffer_radio, 1)
        self.destination_group.setId(self.library_radio, 2)

        self.name_edit.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp('[\x20-\x7f°]*')))
        self.cat_combo.addItems(categories)
        self.bank_combo.addItems([uppercase[b] for b in range(8)])
        self.single_dump_btn.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_ArrowRight))
        self.apply_btn.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogApplyButton))

        self.file_open_btn.clicked.connect(self.file_open)
        self.sounds_table.currentChanged = self.currentChanged
        self.sounds_table.selectionChanged = self.selectionChanged
        self.sounds_table.customContextMenuRequested.connect(self.sound_menu)
        self.sounds_table.cellDoubleClicked.connect(self.dump_temp)
        self.check_btn.clicked.connect(lambda: self.check_selection(True))
        self.uncheck_btn.clicked.connect(lambda: self.check_selection(False))
        self.single_dump_btn.clicked.connect(self.dump_single)
        self.bankmap_btn.clicked.connect(self.bankmap_update)

        self.name_edit.textChanged.connect(
            lambda t: self.apply_btn.setEnabled(True))
        self.cat_combo.currentIndexChanged.connect(
            lambda i: self.apply_btn.setEnabled(True))
        self.apply_btn.clicked.connect(self.sound_update)
Ejemplo n.º 16
0
 def fullText(self):
     reg = "[a-z/s/w]{25}"
     regEx = QtCore.QRegExp(reg)
     validator = QtGui.QRegExpValidator(regEx)
     return validator
Ejemplo n.º 17
0
    def highlightBlock(self, text):

        normalFormat = QtGui.QTextCharFormat()
        normalFormat.setForeground(QtCore.Qt.black)

        macroFormat = QtGui.QTextCharFormat()
        macroFormat.setFontWeight(QtGui.QFont.Bold)
        macroFormat.setForeground(QtCore.Qt.darkRed)
        macroMathFormat = QtGui.QTextCharFormat()
        macroMathFormat.setForeground(QtGui.QColor(140, 140, 100))
        macroPattern = "\\\\([a-zA-Z][a-zA-Z0-9]*|\W)"

        beginendFormat = QtGui.QTextCharFormat()
        beginendFormat.setFontWeight(QtGui.QFont.Bold)
        beginendFormat.setForeground(QtCore.Qt.red)
        beginendPattern = "(\\\\begin\{|\\\\end\{)"

        beginend2Format = QtGui.QTextCharFormat()
        beginend2Format.setFontWeight(QtGui.QFont.Bold)
        beginend2Format.setForeground(QtCore.Qt.blue)

        commentFormat = QtGui.QTextCharFormat()
        commentFormat.setForeground(QtCore.Qt.darkGray)
        commentFormat.setFontItalic(True)
        commentPattern = "%[^\n]*"

        mathFormat = QtGui.QTextCharFormat()
        mathFormat.setForeground(QtGui.QColor(90, 160, 90))
        mathPattern = "(\${1,2}"
        mathPattern += "|\\\\begin\{align\W*\}|\\\\end\{align\W*\}"
        mathPattern += "|\\\\begin\{equation\W*\}|\\\\end\{equation\W*\}"
        mathPattern += "|\\\\begin\{eqnarray\W*\}|\\\\end\{eqnarray\W*\}"
        mathPattern += "|\\\\\(|\\\\\)"
        mathPattern += "|\\\\\[|\\\\\])"



        #Comment highlighting
        expression = QtCore.QRegExp(commentPattern)
        index = expression.indexIn(text)
        commentIndex = text.length()+1
        if (index >= 0):
            commentIndex = index
            self.setFormat(index, text.length()-index, commentFormat)

        #Math highlighting
        mathIndex = []
        self.setCurrentBlockState(0)
        expression = QtCore.QRegExp(mathPattern)

        if (self.previousBlockState() != 1 ):
            startIndex = expression.indexIn(text)
            endIndex = expression.indexIn(text, startIndex+expression.matchedLength())
        else:
            endIndex = expression.indexIn(text, 0)
            startIndex = 0


        while (startIndex >= 0):
            if startIndex > commentIndex:
                break
            if (endIndex == -1):
                self.setCurrentBlockState(1)
                mathLength = text.length() - startIndex
            elif commentIndex < endIndex:
                self.setCurrentBlockState(1)
                mathLength = commentIndex - startIndex
	    else:
                self.setCurrentBlockState(0)
                mathLength = endIndex - startIndex + expression.matchedLength()
            self.setFormat(startIndex, mathLength, mathFormat)
            mathIndex += range(startIndex,startIndex+mathLength)
            startIndex = expression.indexIn(text, startIndex + mathLength)
            endIndex = expression.indexIn(text, startIndex+1)


        #Macro highlight
        expression = QtCore.QRegExp(macroPattern)
        index = expression.indexIn(text)
        while (index >= 0):
            length = expression.matchedLength()
            if index > commentIndex:
                break
            if index in mathIndex:
                self.setFormat(index, length, macroMathFormat)
            else:
                self.setFormat(index, length, macroFormat)
            index = expression.indexIn(text, index + length)

        #Begin highlight
        expression = QtCore.QRegExp(beginendPattern)
        e2 = QtCore.QRegExp("\}")
        index = expression.indexIn(text)
        while (index >= 0):
            if index > commentIndex:
                break
            length = expression.matchedLength()
            i2 = e2.indexIn(text, index + length)
            self.setFormat(index, length-1, beginendFormat)
            self.setFormat(index+length-1, 1, normalFormat)
            if i2 > 0 and i2 < commentIndex:
                self.setFormat(index+length, i2-index-length, beginend2Format)
                self.setFormat(i2, 1, normalFormat)
            index = expression.indexIn(text, index + length)
Ejemplo n.º 18
0
    def on_lineEdit_textChanged(self, text):
        search = QtCore.QRegExp(text, QtCore.Qt.CaseInsensitive,
                                QtCore.QRegExp.RegExp)

        self.proxy.setFilterRegExp(search)
    def __init__(self, parent=None):
        super(PythonHighlighter, self).__init__(parent)

        keywordFormat = QtGui.QTextCharFormat()
        keywordFormat.setForeground(QtCore.Qt.darkGreen)
        keywordFormat.setFontWeight(QtGui.QFont.Bold)

        keywordPatterns = [
            "\\bchar\\b", "\\bclass\\b", "\\bconst\\b", "\\bdouble\\b",
            "\\benum\\b", "\\bexplicit\\b", "\\bfriend\\b", "\\binline\\b",
            "\\bint\\b", "\\blong\\b", "\\bnamespace\\b", "\\boperator\\b",
            "\\bprivate\\b", "\\bprotected\\b", "\\bpublic\\b", "\\bshort\\b",
            "\\bsignals\\b", "\\bsigned\\b", "\\bslots\\b", "\\bstatic\\b",
            "\\bstruct\\b", "\\btemplate\\b", "\\btypedef\\b",
            "\\btypename\\b", "\\bunion\\b", "\\bunsigned\\b", "\\bvirtual\\b",
            "\\bvoid\\b", "\\bvolatile\\b"
        ] + [
            '\\b' + t + '\\b' for t in [
                'and', 'assert', 'break', 'class', 'continue', 'def', 'del',
                'elif', 'else', 'except', 'exec', 'finally', 'for', 'from',
                'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or',
                'pass', 'print', 'raise', 'return', 'try', 'while', 'yield',
                'None', 'True', 'False'
            ]
        ]

        self.highlightingRules = [(QtCore.QRegExp(pattern), keywordFormat)
                                  for pattern in keywordPatterns]

        classFormat = QtGui.QTextCharFormat()
        classFormat.setFontWeight(QtGui.QFont.Bold)
        classFormat.setForeground(QtCore.Qt.darkBlue)
        self.highlightingRules.append(
            (QtCore.QRegExp("\\bQ[A-Za-z]+\\b"), classFormat))

        singleLineCommentFormat = QtGui.QTextCharFormat()
        singleLineCommentFormat.setForeground(QtCore.Qt.red)
        self.highlightingRules.append(
            (QtCore.QRegExp("//[^\n]*"), singleLineCommentFormat))

        self.multiLineCommentFormat = QtGui.QTextCharFormat()
        self.multiLineCommentFormat.setForeground(QtCore.Qt.red)

        quotationFormat = QtGui.QTextCharFormat()
        quotationFormat.setForeground(QtCore.Qt.darkGreen)
        self.highlightingRules.append(
            (QtCore.QRegExp("\".*\""), quotationFormat))
        self.highlightingRules.append(
            (QtCore.QRegExp("\"\"\".*\"\"\""), quotationFormat))
        self.highlightingRules.append(
            (QtCore.QRegExp("\'.*\'"), quotationFormat))
        self.highlightingRules.append(
            (QtCore.QRegExp("\'\'\'.*\'\'\'"), quotationFormat))

        functionFormat = QtGui.QTextCharFormat()
        functionFormat.setFontItalic(True)
        functionFormat.setForeground(QtCore.Qt.blue)
        self.highlightingRules.append(
            (QtCore.QRegExp("\\b[A-Za-z0-9_]+(?=\\()"), functionFormat))

        self.commentStartExpression = QtCore.QRegExp("/\\*")
        self.commentEndExpression = QtCore.QRegExp("\\*/")
Ejemplo n.º 20
0
    def __init__(self, viewWidget, isEditor):
        QtGui.QMainWindow.__init__(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.__view = viewWidget
        self.__isEditor = isEditor
        self.__mutable = False
        self.__utiPixmap = None
        self.__storeButtons = {}
        self.__referrer = None
        self.setCentralWidget(self.__view)

        viewWidget.revChanged.connect(self.__extractMetaData)
        viewWidget.mutable.connect(self.__setMutable)
        viewWidget.distributionChanged.connect(self.__updateStoreButtons)

        # create standard actions
        if isEditor:
            self.__saveAct = QtGui.QAction(QtGui.QIcon('icons/save.png'),
                                           "Check&point", self)
            self.__saveAct.setEnabled(False)
            self.__saveAct.setShortcut(QtGui.QKeySequence.Save)
            self.__saveAct.setStatusTip("Create checkpoint of document")
            QtCore.QObject.connect(self.__saveAct,
                                   QtCore.SIGNAL("triggered()"),
                                   self.__checkpointFile)
            self.__view.checkpointNeeded.connect(
                lambda e: self.__saveAct.setEnabled(e))

            self.__revertAct = QtGui.QAction(QtGui.QIcon('icons/undo.png'),
                                             "Revert", self)
            self.__revertAct.setEnabled(False)
            self.__revertAct.setStatusTip("Revert to the last checkpoint")
            self.__revertAct.triggered.connect(self.__revertFile)
            self.__view.checkpointNeeded.connect(
                lambda e: self.__revertAct.setEnabled(e))

            self.__mergeMenu = QtGui.QMenu()
            self.__mergeMenu.aboutToShow.connect(self.__mergeShow)
            self.__mergeAct = QtGui.QAction(QtGui.QIcon('icons/merge.png'),
                                            "Merge", self)
            self.__mergeAct.setStatusTip(
                "Merge other revisions into current document")
            self.__mergeAct.setMenu(self.__mergeMenu)
            self.__mergeAct.triggered.connect(
                lambda: self.__mergeMenu.exec_(QtGui.QCursor.pos()))
            self.__mergeAct.setVisible(False)
            self.__view.mergeNeeded.connect(
                lambda e: self.__mergeAct.setVisible(e))

            self.__stickyAct = QtGui.QAction("Sticky", self)
            self.__stickyAct.setStatusTip(
                "Automatically replicate referenced documents")
            self.__stickyAct.setCheckable(True)
            self.__stickyAct.setEnabled(False)
            self.__stickyAct.triggered.connect(self.__toggleSticky)

        self.__nameEdit = QtGui.QLineEdit()
        self.__tagsEdit = QtGui.QLineEdit()
        self.__tagsEdit.setValidator(
            QtGui.QRegExpValidator(
                QtCore.QRegExp("(\\s*\\w+\\s*(,\\s*\\w+\\s*)*)?"), self))
        self.__descEdit = QtGui.QTextEdit()
        self.__descEdit.setAcceptRichText(False)
        QtCore.QObject.connect(self.__nameEdit,
                               QtCore.SIGNAL("textEdited(const QString&)"),
                               self.__nameChanged)
        QtCore.QObject.connect(self.__tagsEdit,
                               QtCore.SIGNAL("textEdited(const QString&)"),
                               self.__tagsChanged)
        QtCore.QObject.connect(self.__descEdit, QtCore.SIGNAL("textChanged()"),
                               self.__descChanged)
        layout = QtGui.QVBoxLayout()

        gl = QtGui.QGridLayout()
        gl.addWidget(QtGui.QLabel("Title:"), 0, 0)
        gl.addWidget(self.__nameEdit, 0, 1)
        gl.addWidget(QtGui.QLabel("Tags:"), 1, 0)
        gl.addWidget(self.__tagsEdit, 1, 1)
        layout.addLayout(gl)

        layout.addWidget(QtGui.QLabel("Description:"))
        layout.addWidget(self.__descEdit)
        frame = QtGui.QWidget()
        frame.setLayout(layout)
        self._annotationDock = QtGui.QDockWidget("Annotation", self)
        self._annotationDock.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea
                                             | QtCore.Qt.RightDockWidgetArea)
        self._annotationDock.setWidget(frame)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self._annotationDock)
        self._annotationDock.hide()

        self.__propertiesAct = QtGui.QAction("&Properties", self)
        QtCore.QObject.connect(self.__propertiesAct,
                               QtCore.SIGNAL("triggered()"),
                               self.__showProperties)

        self.__delMenu = QtGui.QMenu()
        self.__delMenu.aboutToShow.connect(self.__fillDelMenu)
        self.delAct = QtGui.QAction(QtGui.QIcon('icons/edittrash.png'),
                                    "&Delete", self)
        self.delAct.setStatusTip("Delete the document")
        self.delAct.setMenu(self.__delMenu)
        self.delAct.triggered.connect(self.__delete)

        self.__exitAct = QtGui.QAction("Close", self)
        self.__exitAct.setShortcut("Ctrl+Q")
        self.__exitAct.setStatusTip("Close the document")
        QtCore.QObject.connect(self.__exitAct, QtCore.SIGNAL("triggered()"),
                               self.close)

        # create standard menu
        self.fileMenu = self.menuBar().addMenu("&Document")
        if isEditor:
            self.fileMenu.addAction(self.__saveAct)
            self.fileMenu.addAction(self.__revertAct)
            self.fileMenu.addAction(self.__mergeAct)
        self.fileMenu.addAction(self.delAct)
        if isEditor:
            self.repMenu = self.fileMenu.addMenu("Replication")
            self.repMenu.addAction(self.__stickyAct)
        self.fileMenu.addAction(self.__propertiesAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.__exitAct)

        # standard tool bars
        self.fileToolBar = self.addToolBar("Document")
        self.dragWidget = DragWidget(self.__view)
        self.dragWidget.setPixmap(QtGui.QPixmap("icons/uti/unknown.png"))
        self.fileToolBar.addWidget(self.dragWidget)
        self.fileToolBar.addSeparator()
        if isEditor:
            self.fileToolBar.addAction(self.__saveAct)
            self.fileToolBar.addAction(self.__mergeAct)
        self.fileToolBar.addAction(self.delAct)
        self.fileToolBar.addAction(self._annotationDock.toggleViewAction())

        # save comment popup
        self.__commentPopup = CommentPopup(self,
                                           lambda c: self.__view.checkpoint(c))

        # disable for now
        self.delAct.setEnabled(True)
Ejemplo n.º 21
0
 def controlrx(self, regexpr):
     rx = QtCore.QRegExp(regexpr)
     validator = QtGui.QRegExpValidator(rx, self)
     self.setValidator(validator)
     return self
Ejemplo n.º 22
0
    def __init__(self, parent):
        super(FormWidget, self).__init__(parent)
        # 是否手動選擇VPN
        self.IsManuallyChooseVPN = False
        # 手動選出來的VPN列表 要傳遞給vpn class
        self.ManuallyVPNServer = None
        # VPN list的表頭
        self.VPNheader = None

        # ====================設定左邊layout 用來呈現訂票介面 裡面包含ticketInfo Layout====================
        self.leftLayout = QtGui.QGridLayout()

        # =============設定left layout的上方控件
        self.lbID = QtGui.QLabel(u"身份證字號:")
        self.lbID.setObjectName(u"lbID")
        self.leftLayout.addWidget(self.lbID, 0, 0)
        self.textID = QtGui.QLineEdit()
        self.textID.setObjectName(u"textID")
        reg_ex = QtCore.QRegExp("^[A-Za-z]{1}[12]{1}[0-9]{8}$")
        textID_validator = QtGui.QRegExpValidator(reg_ex, self)
        self.textID.setValidator(textID_validator)
        self.leftLayout.addWidget(self.textID, 0, 1)

        self.submitBtn = QtGui.QPushButton(u'啟動')
        self.submitBtn.setFont(QtGui.QFont('微軟正黑體', 20))
        self.submitBtn.setFixedSize(150, 70)
        self.submitBtn.setIcon(QtGui.QIcon('img/power.png'))
        self.submitBtn.setIconSize(QtCore.QSize(40, 40))
        self.submitBtn.clicked.connect(lambda: self.Start(self))
        self.leftLayout.addWidget(self.submitBtn, 0, 3, 2, 2)

        self.vpnBtn = QtGui.QPushButton(u'開啟跳板')
        self.vpnBtn.setFixedSize(150, 40)
        self.vpnBtn.setIcon(QtGui.QIcon('img/vpn.png'))
        self.vpnBtn.setIconSize(QtCore.QSize(40, 40))
        self.vpnBtn.clicked.connect(lambda: self.OpenVPN(self))
        self.leftLayout.addWidget(self.vpnBtn, 2, 3, 2, 2)

        self.lb_StartStation = QtGui.QLabel(u'起站代碼')
        self.leftLayout.addWidget(self.lb_StartStation, 1, 0, 1, 1)
        self.cb_StartStation = ExtendedComboBox()
        self.cbStationAddItem(self.cb_StartStation)
        self.leftLayout.addWidget(self.cb_StartStation, 1, 1, 1, 1)

        self.lb_EndStation = QtGui.QLabel(u'到站代碼')
        self.leftLayout.addWidget(self.lb_EndStation, 2, 0, 1, 1)
        self.cb_EndStation = ExtendedComboBox()
        self.cbStationAddItem(self.cb_EndStation)
        self.leftLayout.addWidget(self.cb_EndStation, 2, 1, 1, 1)

        # =============ticketInfo Layout 用來放置去回程的控件
        self.TicketInfolayout = QtGui.QGridLayout()
        self.leftLayout.addLayout(self.TicketInfolayout, 4, 0, 10, 5)

        # =============設定位在ticketInfo裡的出發layout
        self.GoLayout = QtGui.QGroupBox()
        self.GoLayout.setTitle(u'【出發/單程】')
        vbox = QtGui.QGridLayout()
        self.lb_Go_Date = QtGui.QLabel(u'乘車日期')
        vbox.addWidget(self.lb_Go_Date, 0, 0, 1, 2)
        self.cb_Go_Date = QtGui.QComboBox()
        self.cbDateAddItem(self.cb_Go_Date)
        vbox.addWidget(self.cb_Go_Date, 0, 3, 1, 2)

        self.lb_Go_Num = QtGui.QLabel(u'訂票張數')
        vbox.addWidget(self.lb_Go_Num, 1, 0, 1, 2)
        self.cb_Go_Num = QtGui.QComboBox()
        self.cbNumAddItem(self.cb_Go_Num)
        vbox.addWidget(self.cb_Go_Num, 1, 3, 1, 1)

        self.lb_Go_Kind = QtGui.QLabel(u'車種')
        vbox.addWidget(self.lb_Go_Kind, 2, 0, 1, 2)
        self.cb_Go_Kind = QtGui.QComboBox()
        self.cbKindAddItem(self.cb_Go_Kind)
        vbox.addWidget(self.cb_Go_Kind, 2, 3, 1, 2)

        self.lb_Go_StartTime = QtGui.QLabel(u'起始時間')
        vbox.addWidget(self.lb_Go_StartTime, 3, 0, 1, 2)
        self.cb_Go_StartTime = QtGui.QComboBox()
        self.cbTimeAddItem(self.cb_Go_StartTime)
        vbox.addWidget(self.cb_Go_StartTime, 3, 3, 1, 1)

        self.lb_Go_EndTime = QtGui.QLabel(u'截止時間')
        vbox.addWidget(self.lb_Go_EndTime, 4, 0, 1, 2)
        self.cb_Go_EndTime = QtGui.QComboBox()
        self.cbTimeAddItem(self.cb_Go_EndTime)
        vbox.addWidget(self.cb_Go_EndTime, 4, 3, 1, 1)

        self.GoLayout.setLayout(vbox)
        self.TicketInfolayout.addWidget(self.GoLayout, 0, 0, 1, 3)

        # =============設定位在ticketInfo裡的回程layout
        self.BackLayout = QtGui.QGroupBox()
        self.BackLayout.setTitle(u'【回程】')
        self.BackLayout.setCheckable(True)
        backBox = QtGui.QGridLayout()

        self.lb_Back_Date = QtGui.QLabel(u'乘車日期')
        backBox.addWidget(self.lb_Back_Date, 0, 0, 1, 2)
        self.cb_Back_Date = QtGui.QComboBox()
        self.cbDateAddItem(self.cb_Back_Date)
        backBox.addWidget(self.cb_Back_Date, 0, 3, 1, 2)

        self.lb_Back_Num = QtGui.QLabel(u'訂票張數')
        backBox.addWidget(self.lb_Back_Num, 1, 0, 1, 2)
        self.cb_Back_Num = QtGui.QComboBox()
        self.cbNumAddItem(self.cb_Back_Num)
        backBox.addWidget(self.cb_Back_Num, 1, 3, 1, 1)

        self.lb_Back_Kind = QtGui.QLabel(u'車種')
        backBox.addWidget(self.lb_Back_Kind, 2, 0, 1, 2)
        self.cb_Back_Kind = QtGui.QComboBox()
        self.cbKindAddItem(self.cb_Back_Kind)
        backBox.addWidget(self.cb_Back_Kind, 2, 3, 1, 2)

        self.lb_Back_StartTime = QtGui.QLabel(u'起始時間')
        backBox.addWidget(self.lb_Back_StartTime, 3, 0, 1, 2)
        self.cb_Back_StartTime = QtGui.QComboBox()
        self.cbTimeAddItem(self.cb_Back_StartTime)
        backBox.addWidget(self.cb_Back_StartTime, 3, 3, 1, 1)

        self.lb_Back_EndTime = QtGui.QLabel(u'截止時間')
        backBox.addWidget(self.lb_Back_EndTime, 4, 0, 1, 2)
        self.cb_Back_EndTime = QtGui.QComboBox()
        self.cbTimeAddItem(self.cb_Back_EndTime)
        backBox.addWidget(self.cb_Back_EndTime, 4, 3, 1, 1)

        self.BackLayout.setLayout(backBox)
        self.TicketInfolayout.addWidget(self.BackLayout, 0, 3, 1, 3)

        # ====================設定右方layout====================
        self.rightLayout = QtGui.QGridLayout()
        self.lbPicBox = QtGui.QLabel(u'驗證碼:')
        self.rightLayout.addWidget(self.lbPicBox, 0, 0)
        self.captchaPic = QtGui.QLabel()
        self.captchaPic.setFixedSize(203, 62)
        self.captchaPic.setStyleSheet('border:1px solid rgb(0, 0, 0)')
        self.rightLayout.addWidget(self.captchaPic, 1, 0, 3, 2)

        self.groupBoxGoResult = QtGui.QGroupBox()
        self.groupBoxGoResult.setStyleSheet(
            "QGroupBox { background-color: rgb(255, 228,\
        224); border:1px solid rgb(122, 16, 0); }")
        self.groupBoxGoResult.setTitle(u'【去程訂票結果】')
        gorBox = QtGui.QVBoxLayout()
        self.Go_resultMsg = QtGui.QLabel()  #  用來顯示訂票結果
        self.Go_resultMsg.setStyleSheet('QLabel {color: red}')
        gorBox.addWidget(self.Go_resultMsg)
        self.groupBoxGoResult.setLayout(gorBox)
        self.rightLayout.addWidget(self.groupBoxGoResult, 5, 0, 4, 3)

        self.groupBoxBackResult = QtGui.QGroupBox()
        self.groupBoxBackResult.setStyleSheet(
            "QGroupBox { background-color: rgb(255, 228,\
        224); border:1px solid rgb(122, 16, 0); }")
        self.groupBoxBackResult.setTitle(u'【回程訂票結果】')
        backrBox = QtGui.QVBoxLayout()
        self.Back_resultMsg = QtGui.QLabel()  #  用來顯示訂票結果
        self.Back_resultMsg.setStyleSheet('QLabel {color: red}')
        backrBox.addWidget(self.Back_resultMsg)
        self.groupBoxBackResult.setLayout(backrBox)
        self.rightLayout.addWidget(self.groupBoxBackResult, 9, 0, 4, 3)

        # self.rightLayout.setRowMinimumHeight(4, 220)   #用來填補下面空白的部份

        # ==============設定下方log專用layout====================
        self.buttomLayout = QtGui.QGridLayout()
        self.lbLog = QtGui.QLabel(u'【狀態】')
        self.buttomLayout.addWidget(self.lbLog, 0, 0)
        self.clearBtn = QtGui.QPushButton(u'清除')
        self.clearBtn.clicked.connect(self.clearLog)
        self.buttomLayout.addWidget(self.clearBtn, 0, 4, 1, 1)
        self.textBrowser = QtGui.QPlainTextEdit()
        self.textBrowser.setReadOnly(True)
        self.buttomLayout.addWidget(self.textBrowser, 1, 0, 1, 5)

        # ====================主要layout======================
        self.mainLayout = QtGui.QGridLayout()
        self.mainLayout.addLayout(self.leftLayout, 0, 0)
        # 分隔線
        line = QtGui.QFrame()
        line.setFrameStyle(QtGui.QFrame.VLine | QtGui.QFrame.Sunken)
        self.mainLayout.addWidget(line, 0, 1)
        self.mainLayout.addLayout(self.rightLayout, 0, 2)
        # 分隔線
        hline = QtGui.QFrame()
        hline.setFrameStyle(QtGui.QFrame.HLine | QtGui.QFrame.Sunken)
        self.mainLayout.addWidget(hline, 1, 0, 1, 5)
        self.mainLayout.addLayout(self.buttomLayout, 2, 0, 1, 5)
        self.setLayout(self.mainLayout)
Ejemplo n.º 23
0
 def filterRegExpChanged(self, value):
     regExp = QtCore.QRegExp(value)
     self.xrefwindow.proxyModel.setFilterRegExp(regExp)
    def __init__(self, parent=None, app=None):

        self.name = 'GUIFileManagerGroupControl'
        self.myapp = app
        QtGui.QWidget.__init__(self, parent)

        self.setGeometry(10, 25, 120, 300)
        self.setWindowTitle('File Manager Select & Action GUI')
        #self.setWindowIcon(cp.icon_monitor)
        self.palette = QtGui.QPalette()
        self.resetColorIsSet = False

        self.setFrame()

        #cp.setIcons()

        self.setParams()

        self.lab_from = QtGui.QLabel('for run range')
        self.lab_to = QtGui.QLabel(':')
        self.edi_from = QtGui.QLineEdit(self.str_run_from)
        self.edi_to = QtGui.QLineEdit(self.str_run_to)

        self.edi_from.setValidator(QtGui.QIntValidator(0, 9999, self))
        self.edi_to.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp("[0-9]\\d{0,3}|end$"), self))

        self.but_move = QtGui.QPushButton('-> Move ->')
        self.but_copy = QtGui.QPushButton('-> Copy -> ')
        self.but_delete = QtGui.QPushButton('Delete')
        self.but_list = QtGui.QPushButton('<- List')
        self.but_view = QtGui.QPushButton('<- View')
        self.but_plot = QtGui.QPushButton('<- Plot')
        #self.but_copy  .setIcon(cp.icon_monitor)

        self.hboxC = QtGui.QHBoxLayout()
        #self.hboxC.addStretch(1)
        self.hboxC.addWidget(self.edi_from)
        self.hboxC.addWidget(self.lab_to)
        self.hboxC.addWidget(self.edi_to)
        self.hboxC.addStretch(1)

        self.vboxW = QtGui.QVBoxLayout()
        self.vboxW.addStretch(1)
        self.vboxW.addWidget(self.but_list)
        self.vboxW.addWidget(self.but_view)
        self.vboxW.addWidget(self.but_plot)
        self.vboxW.addWidget(self.but_delete)
        self.vboxW.addStretch(1)
        self.vboxW.addWidget(self.but_move)
        self.vboxW.addWidget(self.but_copy)
        self.vboxW.addWidget(self.lab_from)
        self.vboxW.addLayout(self.hboxC)
        self.vboxW.addStretch(1)

        self.setLayout(self.vboxW)

        self.connect(self.but_move, QtCore.SIGNAL('clicked()'), self.onButMove)
        self.connect(self.but_copy, QtCore.SIGNAL('clicked()'), self.onButCopy)
        self.connect(self.but_list, QtCore.SIGNAL('clicked()'), self.onButList)
        self.connect(self.but_view, QtCore.SIGNAL('clicked()'), self.onButView)
        self.connect(self.but_plot, QtCore.SIGNAL('clicked()'), self.onButPlot)
        self.connect(self.but_delete, QtCore.SIGNAL('clicked()'),
                     self.onButDelete)
        self.connect(self.edi_from, QtCore.SIGNAL('editingFinished()'),
                     self.onEdiFrom)
        self.connect(self.edi_to, QtCore.SIGNAL('editingFinished()'),
                     self.onEdiTo)

        self.showToolTips()
        self.setStyle()

        cp.guifilemanagercontrol = self
        self.move(10, 25)
Ejemplo n.º 25
0
 def setFilter(self):
     flt_keys = []
     [flt_keys.append(self.sender().model().data(fl, QtCore.Qt.DisplayRole)) for fl in
      self.sender().selectedIndexes()]
     self.table.model().setFilterKeyColumn(gui.actions[self.ac_name]['header'].index('Клиент'))
     self.table.model().setFilterRegExp(QtCore.QRegExp('|'.join(flt_keys)))
    def __init__(self, parent=None, app=None):

        self.name = 'GUIFileManagerSelect'
        self.myapp = app
        QtGui.QWidget.__init__(self, parent)

        self.setGeometry(10, 25, 630, 120)
        self.setWindowTitle('File Manager Select & Action GUI')
        #self.setWindowIcon(cp.icon_monitor)
        self.palette = QtGui.QPalette()
        self.resetColorIsSet = False

        self.setFrame()

        #cp.setIcons()

        self.path_fm_selected = ''
        self.setParams()

        self.lab_src = QtGui.QLabel('for detector')
        self.lab_type = QtGui.QLabel('calib type')
        self.lab_from = QtGui.QLabel('valid from run')
        self.lab_to = QtGui.QLabel('to')
        self.edi_from = QtGui.QLineEdit(self.str_run_from)
        self.edi_to = QtGui.QLineEdit(self.str_run_to)
        self.but_src = QtGui.QPushButton(self.source_name + self.char_expand)
        self.but_type = QtGui.QPushButton(self.calib_type + self.char_expand)

        self.edi_from.setValidator(QtGui.QIntValidator(0, 9999, self))
        self.edi_to.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp("[0-9]\\d{0,3}|end$"), self))

        self.lab_file = QtGui.QLabel('File:')
        self.edi_file = QtGui.QLineEdit(
            self.path_fm_selected)  # fnm.path_to_calib_dir() )
        self.edi_file.setReadOnly(True)

        self.but_move = QtGui.QPushButton('Move')
        self.but_copy = QtGui.QPushButton('Copy')
        self.but_delete = QtGui.QPushButton('Delete')
        self.but_view = QtGui.QPushButton('View')
        self.but_plot = QtGui.QPushButton('Plot')
        #self.but_copy  .setIcon(cp.icon_monitor)

        self.but_browse = QtGui.QPushButton('Browse')

        self.hboxB = QtGui.QHBoxLayout()
        #self.hboxB.addStretch(1)
        self.hboxB.addWidget(self.lab_file)
        self.hboxB.addWidget(self.edi_file)
        self.hboxB.addWidget(self.but_browse)
        self.hboxB.addStretch(1)

        self.hboxD = QtGui.QHBoxLayout()
        #self.hboxD.addSpacing(50)
        self.hboxD.addWidget(self.but_view)
        self.hboxD.addWidget(self.but_plot)
        self.hboxD.addWidget(self.but_delete)
        self.hboxD.addStretch(1)

        self.hboxC = QtGui.QHBoxLayout()
        #self.hboxC.addStretch(1)
        self.hboxC.addWidget(self.but_move)
        self.hboxC.addWidget(self.but_copy)
        self.hboxC.addWidget(self.lab_src)
        self.hboxC.addWidget(self.but_src)
        self.hboxC.addWidget(self.lab_type)
        self.hboxC.addWidget(self.but_type)
        self.hboxC.addWidget(self.lab_from)
        self.hboxC.addWidget(self.edi_from)
        self.hboxC.addWidget(self.lab_to)
        self.hboxC.addWidget(self.edi_to)
        self.hboxC.addStretch(1)

        self.vboxW = QtGui.QVBoxLayout()
        self.vboxW.addStretch(1)
        self.vboxW.addLayout(self.hboxB)
        self.vboxW.addLayout(self.hboxD)
        self.vboxW.addLayout(self.hboxC)
        self.vboxW.addStretch(1)

        self.setLayout(self.vboxW)

        self.connect(self.but_browse, QtCore.SIGNAL('clicked()'),
                     self.onButBrowse)
        self.connect(self.but_move, QtCore.SIGNAL('clicked()'), self.onButMove)
        self.connect(self.but_copy, QtCore.SIGNAL('clicked()'), self.onButCopy)
        self.connect(self.but_view, QtCore.SIGNAL('clicked()'), self.onButView)
        self.connect(self.but_plot, QtCore.SIGNAL('clicked()'), self.onButPlot)
        self.connect(self.but_delete, QtCore.SIGNAL('clicked()'),
                     self.onButDelete)
        self.connect(self.but_src, QtCore.SIGNAL('clicked()'), self.onButSrc)
        self.connect(self.but_type, QtCore.SIGNAL('clicked()'), self.onButType)
        self.connect(self.edi_from, QtCore.SIGNAL('editingFinished()'),
                     self.onEdiFrom)
        self.connect(self.edi_to, QtCore.SIGNAL('editingFinished()'),
                     self.onEdiTo)

        self.showToolTips()
        self.setStyle()

        cp.guifilemanagerselect = self
        self.move(10, 25)
Ejemplo n.º 27
0
 def setEdiValidators(self):
     self.edi_from.setValidator(QtGui.QIntValidator(0,9999,self))
     self.edi_to  .setValidator(QtGui.QRegExpValidator(QtCore.QRegExp("[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|end$"),self))
Ejemplo n.º 28
0
    def _setupCommentsPattern(self):
        commentsFormat = QtGui.QTextCharFormat()
        commentsFormat.setForeground(QtCore.Qt.blue)

        self.highlightRules.append((QtCore.QRegExp("#[^\n]*"), commentsFormat))
Ejemplo n.º 29
0
 def filter(self, text):
     text = unicode(text)
     self.proxymodel.setFilterRegExp(
         QtCore.QRegExp(text, QtCore.Qt.CaseInsensitive,
                        QtCore.QRegExp.FixedString))
Ejemplo n.º 30
0
 def set_validator(self):
     """ Validate input fields in gui
     :return:
     """
     regex = QtCore.QRegExp("[0-9 ]+")
     number_validator = QtGui.QRegExpValidator(regex)