def setup_ui(self): """create UI widgets """ self.resize(447, 546) self.setWindowTitle("TimeLog Dialog") # ----------------------------- # Setup Main Layout self.main_layout = QtWidgets.QHBoxLayout(self) # create the left column self.left_layout = QtWidgets.QVBoxLayout() self.main_layout.addLayout(self.left_layout) # create the right column # this will list the previously entered time logs self.right_layout = QtWidgets.QVBoxLayout() self.main_layout.addLayout(self.right_layout) # ----------------------------- # Setup Form Layout self.form_layout = QtWidgets.QFormLayout() self.form_layout.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow ) self.left_layout.addLayout(self.form_layout) # ----------------------------- # Tasks self.tasks_label = QtWidgets.QLabel(self) self.tasks_label.setText("Task") self.form_layout.setWidget( 0, QtWidgets.QFormLayout.LabelRole, self.tasks_label ) from anima.ui.widgets import TaskComboBox self.tasks_combo_box = TaskComboBox(self) self.tasks_combo_box.setObjectName("tasks_combo_box") self.form_layout.setWidget( 0, QtWidgets.QFormLayout.FieldRole, self.tasks_combo_box ) # ----------------------------- # Tasks Progress Bar self.task_progress_bar = QtWidgets.QProgressBar(self) self.task_progress_bar.setProperty("value", 24) self.form_layout.setWidget( 1, QtWidgets.QFormLayout.FieldRole, self.task_progress_bar ) # ----------------------------- # Resources self.resources_label = QtWidgets.QLabel(self) self.resources_label.setText("Resource") self.form_layout.setWidget( 2, QtWidgets.QFormLayout.LabelRole, self.resources_label ) self.resource_combo_box = QtWidgets.QComboBox(self) self.form_layout.setWidget( 2, QtWidgets.QFormLayout.FieldRole, self.resource_combo_box ) # ----------------------------- # Calendar, Start & End Time # Label self.date_label = QtWidgets.QLabel(self) self.date_label.setText("Date") self.form_layout.setWidget( 3, QtWidgets.QFormLayout.LabelRole, self.date_label ) # Calendar Widget self.calendar_widget = QtWidgets.QCalendarWidget(self) self.calendar_widget.setFirstDayOfWeek(QtCore.Qt.Monday) self.form_layout.setWidget( 3, QtWidgets.QFormLayout.FieldRole, self.calendar_widget ) # Start Time self.start_time_label = QtWidgets.QLabel(self) self.start_time_label.setText("Start") self.form_layout.setWidget( 4, QtWidgets.QFormLayout.LabelRole, self.start_time_label ) from anima.ui.widgets import TimeEdit self.start_time_edit = TimeEdit(self, resolution=timing_resolution) self.start_time_edit.setCurrentSection( QtWidgets.QDateTimeEdit.MinuteSection ) self.start_time_edit.setCalendarPopup(True) self.start_time_edit.setObjectName("start_time_edit") self.start_time_edit.setWrapping(True) self.form_layout.setWidget( 4, QtWidgets.QFormLayout.FieldRole, self.start_time_edit ) self.start_time_edit.setDisplayFormat("HH:mm") # End Time self.end_time_label = QtWidgets.QLabel(self) self.end_time_label.setText("End") self.form_layout.setWidget( 5, QtWidgets.QFormLayout.LabelRole, self.end_time_label ) self.end_time_edit = TimeEdit(self, resolution=timing_resolution) self.end_time_edit.setCurrentSection( QtWidgets.QDateTimeEdit.MinuteSection ) self.end_time_edit.setCalendarPopup(True) self.end_time_edit.setObjectName("end_time_edit") self.end_time_edit.setWrapping(True) self.form_layout.setWidget( 5, QtWidgets.QFormLayout.FieldRole, self.end_time_edit ) self.end_time_edit.setDisplayFormat("HH:mm") # ----------------------------- # Time Left Info self.info_area_label = QtWidgets.QLabel(self) self.info_area_label.setText("INFO") self.form_layout.setWidget( 6, QtWidgets.QFormLayout.FieldRole, self.info_area_label ) # ----------------------------- # Revision self.revision_label = QtWidgets.QLabel(self) self.revision_label.setText( """<html> <head/> <body> <p align=\"right\"> Revision <br/> Type </p> </body> </html> """ ) self.form_layout.setWidget( 7, QtWidgets.QFormLayout.LabelRole, self.revision_label ) self.revision_type_combo_box = QtWidgets.QComboBox(self) self.form_layout.setWidget( 7, QtWidgets.QFormLayout.FieldRole, self.revision_type_combo_box ) # ----------------------------- # Description self.description_label = QtWidgets.QLabel(self) self.description_label.setText("Description") self.form_layout.setWidget( 8, QtWidgets.QFormLayout.LabelRole, self.description_label ) self.description_plain_text_edit = QtWidgets.QPlainTextEdit(self) self.form_layout.setWidget( 8, QtWidgets.QFormLayout.FieldRole, self.description_plain_text_edit ) # ----------------------------- # Status self.status_label = QtWidgets.QLabel(self) self.status_label.setText("Status") self.form_layout.setWidget( 9, QtWidgets.QFormLayout.LabelRole, self.status_label ) self.not_finished_yet_radio_button = QtWidgets.QRadioButton(self) self.not_finished_yet_radio_button.setText("Not Finished Yet") self.not_finished_yet_radio_button.setChecked(True) self.form_layout.setWidget( 9, QtWidgets.QFormLayout.FieldRole, self.not_finished_yet_radio_button ) self.set_as_complete_radio_button = QtWidgets.QRadioButton(self) self.set_as_complete_radio_button.setText("Set As Complete") self.form_layout.setWidget( 10, QtWidgets.QFormLayout.FieldRole, self.set_as_complete_radio_button ) self.submit_for_final_review_radio_button = \ QtWidgets.QRadioButton(self) self.submit_for_final_review_radio_button.setText( "Submit For Final Review" ) self.form_layout.setWidget( 11, QtWidgets.QFormLayout.FieldRole, self.submit_for_final_review_radio_button ) # ----------------------------- # Dialog Button Box self.dialog_button_box = QtWidgets.QDialogButtonBox(self) self.dialog_button_box.setOrientation(QtCore.Qt.Horizontal) self.dialog_button_box.setStandardButtons( QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok ) self.left_layout.addWidget(self.dialog_button_box) # create the right column which is the current date details self.formatted_date_label = QtWidgets.QLabel(self) self.formatted_date_label.setText("") self.right_layout.addWidget(self.formatted_date_label) # create the right column which is the current date details self.time_log_info_label = QtWidgets.QLabel(self) self.time_log_info_label.setText("") self.right_layout.addWidget(self.time_log_info_label) # set stretch self.main_layout.setStretchFactor(self.left_layout, 0) self.main_layout.setStretchFactor(self.right_layout, 1) # setup signals self._setup_signals() # setup defaults self._set_defaults() # center window self.center_window()
def setup_ui(self): """create the UI widgets """ # we need a main layout # may be a vertical one # or a form layout self.vertical_layout = QtWidgets.QVBoxLayout(self) # ------------------------- # Dialog Label and buttons horizontal_layout3 = QtWidgets.QHBoxLayout() self.vertical_layout.addLayout(horizontal_layout3) self.widget_label = QtWidgets.QLabel(self) self.widget_label.setText(self.task.name if self.task else 'Task Name') self.widget_label.setStyleSheet( "color: rgb(71, 143, 202);\nfont: 18pt;") horizontal_layout3.addWidget(self.widget_label) horizontal_layout3.addStretch(1) # Add Watch Task button self.watch_task_button = QtWidgets.QPushButton(self) self.watch_task_button.setMaximumWidth(24) self.watch_task_button.setMaximumHeight(24) self.watch_task_button.setText("W") self.watch_task_button.setToolTip("Watch Task") self.fix_task_status_button = QtWidgets.QPushButton(self) self.fix_task_status_button.setMaximumWidth(24) self.fix_task_status_button.setMaximumHeight(24) self.fix_task_status_button.setText("F") self.fix_task_status_button.setToolTip("Fix Task Status") horizontal_layout3.addWidget(self.watch_task_button) horizontal_layout3.addWidget(self.fix_task_status_button) # Add Status Label vertical_layout3 = QtWidgets.QVBoxLayout() from anima.ui.widgets.task_status_label import TaskStatusLabel self.task_status_label = TaskStatusLabel(task=self.task) self.task_status_label.setMaximumHeight(12) vertical_layout3.addWidget(self.task_status_label) # Add ProgressBar self.task_progress = QtWidgets.QProgressBar(self) self.task_progress.setMinimum(0) self.task_progress.setMaximum(100) self.task_progress.setValue(50) self.task_progress.setAlignment(QtCore.Qt.AlignCenter) self.task_progress.setMaximumHeight(12) self.task_progress.setStyleSheet(""" QProgressBar::chunk { background-color: #3add36; width: 1px; } """) vertical_layout3.addWidget(self.task_progress) # set items closer to each other vertical_layout3.setSpacing(0) horizontal_layout3.addLayout(vertical_layout3) # Add divider line = QtWidgets.QFrame(self) line.setFrameShape(QtWidgets.QFrame.HLine) line.setFrameShadow(QtWidgets.QFrame.Sunken) self.vertical_layout.addWidget(line) horizontal_layout1 = QtWidgets.QHBoxLayout() self.vertical_layout.addLayout(horizontal_layout1) vertical_layout1 = QtWidgets.QVBoxLayout() vertical_layout2 = QtWidgets.QVBoxLayout() horizontal_layout1.addLayout(vertical_layout1) horizontal_layout1.addLayout(vertical_layout2) # -------------------------- # Horizontal Layout for thumbnail and detail widgets horizontal_layout2 = QtWidgets.QHBoxLayout() vertical_layout1.addLayout(horizontal_layout2) # -------------------------- # Task Thumbnail from anima.ui.widgets.entity_thumbnail import EntityThumbnailWidget self.task_thumbnail_widget = \ EntityThumbnailWidget(task=self.task, parent=self) horizontal_layout2.addWidget(self.task_thumbnail_widget) # -------------------------- # Task Detail Info from anima.ui.widgets.task_detail import TaskDetailWidget self.task_detail_widget = TaskDetailWidget(task=self.task, parent=self) horizontal_layout2.addWidget(self.task_detail_widget) # -------------------------- # Task Timing Info from anima.ui.widgets.task_timing import TaskTimingWidget self.task_timing_widget = TaskTimingWidget(task=self.task, parent=self) horizontal_layout2.addWidget(self.task_timing_widget) # add stretcher # horizontal_layout2.addStretch(1) # -------------------------- # Description field self.description_label = QtWidgets.QLabel(self) self.description_label.setStyleSheet(""" background-color: gray; color: white; font-weight: bold; padding: 0.5em; """) self.description_label.setText("Description") self.description_field = QtWidgets.QTextEdit(self) self.description_field.setAcceptRichText(True) vertical_layout1.addWidget(self.description_label) vertical_layout1.addWidget(self.description_field) # add stretcher vertical_layout1.addStretch(1) # --------------------------- # Responsible Info from anima.ui.widgets.responsible_info import ResponsibleInfoWidget self.responsible_info_widget = ResponsibleInfoWidget(task=self.task, parent=self) vertical_layout2.addWidget(self.responsible_info_widget) # --------------------------- # Resource Info from anima.ui.widgets.resource_info import ResourceInfoWidget self.resource_info_widget = ResourceInfoWidget(task=self.task, parent=self) vertical_layout2.addWidget(self.resource_info_widget) # --------------------------- # Task Versions Usage Info from anima.ui.widgets.task_version_usage_info import \ TaskVersionUsageInfoWidget self.task_versions_usage_info_widget = TaskVersionUsageInfoWidget( task=self.task, parent=self) vertical_layout2.addWidget(self.task_versions_usage_info_widget) vertical_layout2.addStretch(1) horizontal_layout1.setStretch(0, 2) horizontal_layout1.setStretch(1, 1) # --------------------------- # Task Notes from anima.ui.widgets.entity_notes import EntityNotesWidgets self.task_notes_widget = \ EntityNotesWidgets(entity=self.task, parent=self) self.vertical_layout.addWidget(self.task_notes_widget)
def create(self, parent=None): """Creates this publisher :param parent: :return: """ # Create layout self.layout = QtWidgets.QHBoxLayout(parent) # Create Icons self.publisher_state_ok_icon = parent.style() \ .standardIcon(QtWidgets.QStyle.SP_DialogYesButton) self.publisher_state_not_ok_icon = parent.style() \ .standardIcon(QtWidgets.QStyle.SP_DialogNoButton) # Create check push button self.check_push_button = QtWidgets.QPushButton(parent) self.check_push_button.setText('Check') self.layout.addWidget(self.check_push_button) self.check_push_button.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) # Create fix push button self.fix_push_button = QtWidgets.QPushButton(parent) self.fix_push_button.setText('Fix') self.layout.addWidget(self.fix_push_button) self.fix_push_button.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.fix_push_button.setMaximumWidth(40) # Create Progress Bar self.progress_bar = QtWidgets.QProgressBar(parent) self.progress_bar.setFixedWidth(100) self.progress_bar.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.layout.addWidget(self.progress_bar) self.progress_bar_manager = QProgressBarWrapper( progress_bar=self.progress_bar, minimum=0, maximum=100.0, value=0.0) # Create state label self.publisher_state_label = QtWidgets.QLabel(parent) self.publisher_state_label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.layout.addWidget(self.publisher_state_label) # Create performance label self.performance_label = QtWidgets.QLabel(parent) self.performance_label.setText('x.x sec') self.performance_label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.layout.addWidget(self.performance_label) # Create name label self.publisher_name_label = QtWidgets.QLabel(parent) self.publisher_name_label.setText( self.publisher.__doc__.split('\n')[0].strip()) self.publisher_name_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.publisher_name_label.setToolTip(self.publisher.__doc__) self.performance_label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.layout.addWidget(self.publisher_name_label) # Create help push button self.help_push_button = QtWidgets.QPushButton(parent) self.help_push_button.setText('?') self.layout.addWidget(self.help_push_button) self.help_push_button.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.help_push_button.setMaximumWidth(20) spacer = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.layout.addItem(spacer) self.state = False # create button signal QtCore.QObject.connect(self.check_push_button, QtCore.SIGNAL("clicked()"), self.run_publisher) QtCore.QObject.connect(self.help_push_button, QtCore.SIGNAL('clicked()'), self.show_publisher_docs) QtCore.QObject.connect(self.fix_push_button, QtCore.SIGNAL('clicked()'), self.run_fix_definition)
def setup_ui(self): """create UI widgets """ self.resize(447, 546) self.setWindowTitle("TimeLog Dialog") # ----------------------------- # Setup Main Layout self.main_layout = QtWidgets.QHBoxLayout(self) # create the left column self.left_layout = QtWidgets.QVBoxLayout() self.main_layout.addLayout(self.left_layout) # create the right column # this will list the previously entered time logs self.right_layout = QtWidgets.QVBoxLayout() self.main_layout.addLayout(self.right_layout) # ----------------------------- # Setup Form Layout self.form_layout = QtWidgets.QFormLayout() self.form_layout.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow ) self.left_layout.addLayout(self.form_layout) i = 0 # ----------------------------- # Tasks self.tasks_label = QtWidgets.QLabel(self) self.tasks_label.setText("Task") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.tasks_label ) from anima.ui.widgets import TaskComboBox self.tasks_combo_box = TaskComboBox(self) self.tasks_combo_box.setObjectName("tasks_combo_box") self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.tasks_combo_box ) # ----------------------------- # Tasks Progress Bar i += 1 self.task_progress_bar = QtWidgets.QProgressBar(self) self.task_progress_bar.setProperty("value", 24) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.task_progress_bar ) # ----------------------------- # Resources i += 1 self.resources_label = QtWidgets.QLabel(self) self.resources_label.setText("Resource") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.resources_label ) self.resource_combo_box = QtWidgets.QComboBox(self) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.resource_combo_box ) # ----------------------------- # Calendar, Start & End Time i += 1 # Label self.date_label = QtWidgets.QLabel(self) self.date_label.setText("Date") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.date_label ) # Calendar Widget self.calendar_widget = QtWidgets.QCalendarWidget(self) self.calendar_widget.setFirstDayOfWeek(QtCore.Qt.Monday) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.calendar_widget ) # ----------------------------- # Start Time from anima.ui.widgets import TimeEdit i += 1 self.start_time_label = QtWidgets.QLabel(self) self.start_time_label.setText("Start") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.start_time_label ) from anima import TIMING_RESOLUTION self.start_time_edit = TimeEdit(self, resolution=TIMING_RESOLUTION) self.start_time_edit.setCurrentSection(QtWidgets.QDateTimeEdit.MinuteSection) self.start_time_edit.setCalendarPopup(True) self.start_time_edit.setObjectName("start_time_edit") self.start_time_edit.setWrapping(True) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.start_time_edit ) self.start_time_edit.setDisplayFormat("HH:mm") # ----------------------------- # End Time i += 1 self.end_time_label = QtWidgets.QLabel(self) self.end_time_label.setText("End") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.end_time_label ) self.end_time_edit = TimeEdit(self, resolution=TIMING_RESOLUTION) self.end_time_edit.setCurrentSection( QtWidgets.QDateTimeEdit.MinuteSection ) self.end_time_edit.setCalendarPopup(True) self.end_time_edit.setObjectName("end_time_edit") self.end_time_edit.setWrapping(True) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.end_time_edit ) self.end_time_edit.setDisplayFormat("HH:mm") # ----------------------------- # Effort i += 1 # Label self.effort_label = QtWidgets.QLabel(self) self.effort_label.setText("Effort") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.effort_label ) effort_layout = QtWidgets.QHBoxLayout(self) self.form_layout.setLayout( i, QtWidgets.QFormLayout.FieldRole, effort_layout ) self.effort_time_edit = TimeEdit(self, resolution=TIMING_RESOLUTION) self.effort_time_edit.setCurrentSection(QtWidgets.QDateTimeEdit.MinuteSection) self.effort_time_edit.setCalendarPopup(True) self.effort_time_edit.setObjectName("effort_time_edit") self.effort_time_edit.setWrapping(True) # self.form_layout.setWidget( # i, # QtWidgets.QFormLayout.FieldRole, # self.effort_time_edit # ) effort_layout.addWidget(self.effort_time_edit) self.effort_time_edit.setDisplayFormat("HH:mm") # ----------------------------- # Advanced Time Controls self.show_advanced_time_controls_check_box = QtWidgets.QCheckBox(self) self.show_advanced_time_controls_check_box.setText('Advanced Controls') effort_layout.addWidget(self.show_advanced_time_controls_check_box) # ----------------------------- # Time Left Info i += 1 self.info_area_label = QtWidgets.QLabel(self) self.info_area_label.setText("INFO") self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.info_area_label ) # ----------------------------- # Status i += 1 self.status_label = QtWidgets.QLabel(self) self.status_label.setText("Status") self.form_layout.setWidget( i, QtWidgets.QFormLayout.LabelRole, self.status_label ) self.not_finished_yet_radio_button = QtWidgets.QRadioButton(self) self.not_finished_yet_radio_button.setText("Not Finished Yet") self.not_finished_yet_radio_button.setChecked(True) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.not_finished_yet_radio_button ) i += 1 self.set_as_complete_radio_button = QtWidgets.QRadioButton(self) self.set_as_complete_radio_button.setText("Set As Completed") self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.set_as_complete_radio_button ) i += 1 self.submit_for_final_review_radio_button = \ QtWidgets.QRadioButton(self) self.submit_for_final_review_radio_button.setText( "Submit For Final Review" ) self.form_layout.setWidget( i, QtWidgets.QFormLayout.FieldRole, self.submit_for_final_review_radio_button ) # ----------------------------- # Dialog Button Box self.dialog_button_box = QtWidgets.QDialogButtonBox(self) self.dialog_button_box.setOrientation(QtCore.Qt.Horizontal) self.dialog_button_box.setStandardButtons( QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok ) self.left_layout.addWidget(self.dialog_button_box) # create the right column which is the current date details self.formatted_date_label = QtWidgets.QLabel(self) self.formatted_date_label.setText("") self.right_layout.addWidget(self.formatted_date_label) # create the right column which is the current date details self.time_log_info_label = QtWidgets.QLabel(self) self.time_log_info_label.setText("") self.right_layout.addWidget(self.time_log_info_label) # set stretch self.main_layout.setStretchFactor(self.left_layout, 0) self.main_layout.setStretchFactor(self.right_layout, 1) # setup signals self._setup_signals() # setup defaults self._set_defaults() # center window self.center_window()