예제 #1
0
파일: login.py 프로젝트: zero804/kajongg
    def __init__(self, url, username, password):
        KDialog.__init__(self)
        decorateWindow(self, i18n('Create User Account'))
        self.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel))
        vbox = QVBoxLayout()
        grid = QFormLayout()
        self.lbServer = QLabel()
        self.lbServer.setText(url)
        grid.addRow(i18n('Game server:'), self.lbServer)
        self.lbUser = QLabel()
        grid.addRow(i18n('Username:'******'Password:'******'Repeat password:'), self.edPassword2)
        vbox.addLayout(grid)
        widget = QWidget(self)
        widget.setLayout(vbox)
        self.setMainWidget(widget)
        pol = QSizePolicy()
        pol.setHorizontalPolicy(QSizePolicy.Expanding)
        self.lbUser.setSizePolicy(pol)

        self.edPassword.textChanged.connect(self.passwordChanged)
        self.edPassword2.textChanged.connect(self.passwordChanged)
        StateSaver(self)
        self.username = username
        self.password = password
        self.passwordChanged()
        self.edPassword2.setFocus()
    def setup(self):
        self.widget = QWidget()
        layout = QGridLayout()
        self.widget.setLayout(layout)
        self.layout.addWidget(self.widget)
        self.widget.show()
        self.layout = layout

        self.setupInputFrame()
        self.setupFrameControlFrame()
        self.setupAdditionalFrames()
        self.setupPlottingFrame()

        self.setFramesEnabled(False)

        self.timer = QTimer()
        self.timer.setInterval(50)

        self.setupConnections()

        # initialize slice observers (from DataProbe.py)
        # keep list of pairs: [observee,tag] so they can be removed easily
        self.styleObserverTags = []
        # keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
        self.sliceWidgetsPerStyle = {}
        self.refreshObservers()
예제 #3
0
 def setupUi(self):
     """setup UI elements"""
     self.viewLeft = ScoreViewLeft(self)
     self.viewRight = ScoreViewRight(self)
     self.viewRight.setHorizontalScrollBar(HorizontalScrollBar(self))
     self.viewRight.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem)
     self.viewRight.setFocusPolicy(Qt.NoFocus)
     self.viewRight.header().setSectionsClickable(False)
     self.viewRight.header().setSectionsMovable(False)
     self.viewRight.setSelectionMode(QAbstractItemView.NoSelection)
     windowLayout = QVBoxLayout(self)
     self.splitter = QSplitter(Qt.Vertical)
     self.splitter.setObjectName('ScoreTableSplitter')
     windowLayout.addWidget(self.splitter)
     scoreWidget = QWidget()
     self.scoreLayout = QHBoxLayout(scoreWidget)
     leftLayout = QVBoxLayout()
     leftLayout.addWidget(self.viewLeft)
     self.leftLayout = leftLayout
     self.scoreLayout.addLayout(leftLayout)
     self.scoreLayout.addWidget(self.viewRight)
     self.splitter.addWidget(scoreWidget)
     self.ruleTree = RuleTreeView(i18nc('kajongg', 'Used Rules'))
     self.splitter.addWidget(self.ruleTree)
     # this shows just one line for the ruleTree - so we just see the
     # name of the ruleset:
     self.splitter.setSizes(list([1000, 1]))
예제 #4
0
 def setupUiForPlayer(self, pGrid, idx):
     """setup UI elements for a player"""
     self.spValues[idx] = QSpinBox()
     self.nameLabels[idx] = QLabel()
     self.nameLabels[idx].setBuddy(self.spValues[idx])
     self.windLabels[idx] = WindLabel()
     pGrid.addWidget(self.nameLabels[idx], idx + 2, 0)
     pGrid.addWidget(self.windLabels[idx], idx + 2, 1)
     pGrid.addWidget(self.spValues[idx], idx + 2, 2)
     self.wonBoxes[idx] = QCheckBox("")
     pGrid.addWidget(self.wonBoxes[idx], idx + 2, 3)
     self.wonBoxes[idx].clicked.connect(self.wonChanged)
     self.spValues[idx].valueChanged.connect(self.slotInputChanged)
     detailTab = QWidget()
     self.detailTabs.addTab(detailTab, '')
     self.details[idx] = QWidget()
     detailTabLayout = QVBoxLayout(detailTab)
     detailTabLayout.addWidget(self.details[idx])
     detailTabLayout.addStretch()
     self.detailsLayout[idx] = QVBoxLayout(self.details[idx])
예제 #5
0
 def setupPlottingFrame(self, parent=None):
   if not parent:
     parent = self.layout
   self.plottingFrameWidget = QWidget()
   self.plottingFrameLayout = QGridLayout()
   self.plottingFrameWidget.setLayout(self.plottingFrameLayout)
   self._multiVolumeIntensityChart = MultiVolumeIntensityChartView()
   self.popupChartButton = QPushButton("Undock chart")
   self.popupChartButton.setCheckable(True)
   self.plottingFrameLayout.addWidget(self._multiVolumeIntensityChart.chartView)
   self.plottingFrameLayout.addWidget(self.popupChartButton)
   parent.addWidget(self.plottingFrameWidget)
예제 #6
0
 def setupInputFrame(self, parent=None):
   if not parent:
     parent = self.layout
   self.bgMultiVolumeSelector = slicer.qMRMLNodeComboBox()
   self.bgMultiVolumeSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
   self.bgMultiVolumeSelector.setMRMLScene(slicer.mrmlScene)
   self.bgMultiVolumeSelector.addEnabled = 0
   self._bgMultiVolumeSelectorLabel = QLabel('Input multivolume')
   inputFrameWidget = QWidget()
   self.inputFrameLayout = QFormLayout()
   inputFrameWidget.setLayout(self.inputFrameLayout)
   self.inputFrameLayout.addRow(self._bgMultiVolumeSelectorLabel, self.bgMultiVolumeSelector)
   parent.addWidget(inputFrameWidget)
예제 #7
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.btn1 = QPushButton("Click me", self)

        vbox = QVBoxLayout()
        vbox.addWidget(QLabel("A1"))
        vbox.addWidget(self.btn1)
        vbox.addWidget(QLabel("B2"))

        self.btn1.clicked.connect(self.doit)
        self.my_pop = None

        self.main_widget = QWidget(self)
        self.main_widget.setLayout(vbox)
        self.setCentralWidget(self.main_widget)
예제 #8
0
 def setupUi(self):
     """layout the window"""
     decorateWindow(self, i18n('Customize rulesets'))
     self.setObjectName('Rulesets')
     hlayout = QHBoxLayout(self)
     v1layout = QVBoxLayout()
     self.v1widget = QWidget()
     v1layout = QVBoxLayout(self.v1widget)
     v2layout = QVBoxLayout()
     hlayout.addWidget(self.v1widget)
     hlayout.addLayout(v2layout)
     for widget in [self.v1widget, hlayout, v1layout, v2layout]:
         widget.setContentsMargins(0, 0, 0, 0)
     hlayout.setStretchFactor(self.v1widget, 10)
     self.btnCopy = QPushButton()
     self.btnRemove = QPushButton()
     self.btnCompare = QPushButton()
     self.btnClose = QPushButton()
     self.rulesetView = RuleTreeView(
         i18ncE('kajongg',
                'Rule'),
         self.btnCopy,
         self.btnRemove,
         self.btnCompare)
     v1layout.addWidget(self.rulesetView)
     self.rulesetView.setWordWrap(True)
     self.rulesetView.setMouseTracking(True)
     spacerItem = QSpacerItem(
         20,
         20,
         QSizePolicy.Minimum,
         QSizePolicy.Expanding)
     v2layout.addWidget(self.btnCopy)
     v2layout.addWidget(self.btnRemove)
     v2layout.addWidget(self.btnCompare)
     self.btnCopy.clicked.connect(self.rulesetView.copyRow)
     self.btnRemove.clicked.connect(self.rulesetView.removeRow)
     self.btnCompare.clicked.connect(self.rulesetView.compareRow)
     self.btnClose.clicked.connect(self.hide)
     v2layout.addItem(spacerItem)
     v2layout.addWidget(self.btnClose)
     self.retranslateUi()
     StateSaver(self)
     self.show()
예제 #9
0
 def __init__(self, kongs, deferred):
     KDialogIgnoringEscape.__init__(self)
     decorateWindow(self)
     self.setButtons(0)
     self.kongs = kongs
     self.selectedKong = None
     self.deferred = deferred
     layout = QVBoxLayout()
     label = QLabel(i18n('Which kong do you want to declare?'))
     layout.addWidget(label)
     layout.setAlignment(label, Qt.AlignHCenter)
     self.buttons = []
     for kong in kongs:
         button = QRadioButton((kong[0].name()), self)
         self.buttons.append(button)
         layout.addWidget(button)
         button.toggled.connect(self.toggled)
     widget = QWidget(self)
     widget.setLayout(layout)
     self.setMainWidget(widget)
예제 #10
0
 def __init__(self, chows, propose, deferred):
     KDialogIgnoringEscape.__init__(self)
     decorateWindow(self)
     self.setButtons(KDialog.NoButton)
     self.chows = chows
     self.selectedChow = None
     self.deferred = deferred
     layout = QVBoxLayout()
     label = QLabel(i18n('Which chow do you want to expose?'))
     layout.addWidget(label)
     layout.setAlignment(label, Qt.AlignHCenter)
     self.buttons = []
     for chow in chows:
         button = QRadioButton('{}-{}-{}'.format(*(x.value for x in chow)))
         self.buttons.append(button)
         layout.addWidget(button)
         layout.setAlignment(button, Qt.AlignHCenter)
         button.toggled.connect(self.toggled)
     widget = QWidget(self)
     widget.setLayout(layout)
     self.setMainWidget(widget)
     for idx, chow in enumerate(chows):
         if chow == propose:
             self.buttons[idx].setFocus()
예제 #11
0
    def __init__(self, parent=None):
        super(InfoWidget, self).__init__()

        empty_str = "__________"

        beam_group = QGroupBox(" Beam ")
        bm_v_layout = QVBoxLayout()

        bm_v_layout.addLayout(get_spacebox(130))

        xb_label = QLabel("  X (mm) ")
        yb_label = QLabel("  Y (mm) ")

        bm_label_a_layout = QHBoxLayout()
        bm_label_a_layout.addWidget(xb_label)
        bm_label_a_layout.addWidget(yb_label)

        bm_v_layout.addLayout(bm_label_a_layout)

        self.xb_data = QLabel(empty_str)
        self.yb_data = QLabel(empty_str)
        bm_data_layout = QHBoxLayout()
        bm_data_layout.addWidget(self.xb_data)
        bm_data_layout.addWidget(self.yb_data)
        bm_v_layout.addLayout(bm_data_layout)

        bm_v_layout.addWidget(QLabel("  "))

        tmp_str = "  Wavelength (" + u"\u212B" + ") "

        w_lambda_label = QLabel(tmp_str)
        bm_v_layout.addWidget(w_lambda_label)
        self.w_lambda_data = QLabel(empty_str)
        bm_v_layout.addWidget(self.w_lambda_data)
        # bm_v_layout.addWidget(QLabel("  "))

        # bm_v_layout.addStretch()
        beam_group.setLayout(bm_v_layout)

        cell_group = QGroupBox(" Crystal ")
        cell_v_layout = QVBoxLayout()
        cell_v_layout.addLayout(get_spacebox(160))

        a_label = QLabel("    a ")
        b_label = QLabel("    b ")
        c_label = QLabel("    c ")
        cell_label_d_layout = QHBoxLayout()
        cell_label_d_layout.addWidget(a_label)
        cell_label_d_layout.addWidget(b_label)
        cell_label_d_layout.addWidget(c_label)
        cell_v_layout.addLayout(cell_label_d_layout)

        self.a_data = QLabel(empty_str)
        self.b_data = QLabel(empty_str)
        self.c_data = QLabel(empty_str)
        cell_data_layout = QHBoxLayout()
        cell_data_layout.addWidget(self.a_data)
        cell_data_layout.addWidget(self.b_data)
        cell_data_layout.addWidget(self.c_data)
        cell_v_layout.addLayout(cell_data_layout)
        cell_v_layout.addWidget(QLabel("  "))

        left_margin_str = "    "
        alpha_str = left_margin_str + u"\u03B1"
        beta_str = left_margin_str + u"\u03B2"
        gamma_str = left_margin_str + u"\u03B3"

        alpha_label = QLabel(alpha_str)
        beta_label = QLabel(beta_str)
        gamma_label = QLabel(gamma_str)

        cell_label_a_layout = QHBoxLayout()
        cell_label_a_layout.addWidget(alpha_label)
        cell_label_a_layout.addWidget(beta_label)
        cell_label_a_layout.addWidget(gamma_label)
        cell_v_layout.addLayout(cell_label_a_layout)

        self.alpha_data = QLabel(empty_str)
        self.beta_data = QLabel(empty_str)
        self.gamma_data = QLabel(empty_str)
        cell_data_layout = QHBoxLayout()
        cell_data_layout.addWidget(self.alpha_data)
        cell_data_layout.addWidget(self.beta_data)
        cell_data_layout.addWidget(self.gamma_data)
        cell_v_layout.addLayout(cell_data_layout)

        cell_v_layout.addWidget(QLabel("  "))

        spgrp_label = QLabel(" Space Group")
        self.spgrp_data = QLabel(empty_str)
        spgrp_hbox = QHBoxLayout()
        spgrp_hbox.addWidget(spgrp_label)
        spgrp_hbox.addWidget(self.spgrp_data)
        cell_v_layout.addLayout(spgrp_hbox)

        r_layout = QVBoxLayout()
        r_layout.addWidget(QLabel("  "))
        r_layout.addWidget(QLabel(" Orientation (deg) "))

        r_label_layout = QHBoxLayout()
        r1_label = QLabel(" rot X")
        r2_label = QLabel(" rot Y")
        r3_label = QLabel(" rot Z")
        r_label_layout.addWidget(r1_label)
        r_label_layout.addWidget(r2_label)
        r_label_layout.addWidget(r3_label)

        r_data_layout = QHBoxLayout()
        self.r1_data = QLabel(empty_str)
        self.r2_data = QLabel(empty_str)
        self.r3_data = QLabel(empty_str)
        r_data_layout.addWidget(self.r1_data)
        r_data_layout.addWidget(self.r2_data)
        r_data_layout.addWidget(self.r3_data)

        r_layout.addLayout(r_label_layout)
        r_layout.addLayout(r_data_layout)

        crys_v_layout = QVBoxLayout()
        crys_v_layout.addLayout(cell_v_layout)
        crys_v_layout.addLayout(r_layout)
        # crys_v_layout.addStretch()
        cell_group.setLayout(crys_v_layout)

        scan_group = QGroupBox(" Scan ")

        scan_v_layout = QVBoxLayout()
        scan_v_layout.addLayout(get_spacebox(180))
        scan_v_layout.addWidget(QLabel(" Image Range "))

        img_ran_h_layout = QHBoxLayout()
        img_ran1_v_layout = QVBoxLayout()
        # img_ran1_label = QLabel(" from")
        self.img_ran1_data = QLabel(empty_str)
        # img_ran1_v_layout.addWidget(img_ran1_label)
        img_ran1_v_layout.addWidget(self.img_ran1_data)

        img_ran2_v_layout = QVBoxLayout()
        # img_ran2_label = QLabel(" to")
        self.img_ran2_data = QLabel(empty_str)
        # img_ran2_v_layout.addWidget(img_ran2_label)
        img_ran2_v_layout.addWidget(self.img_ran2_data)

        img_ran_h_layout.addLayout(img_ran1_v_layout)
        img_ran_h_layout.addLayout(img_ran2_v_layout)

        scan_v_layout.addLayout(img_ran_h_layout)

        scan_v_layout.addWidget(QLabel("  "))

        oscil_h_layout = QHBoxLayout()
        oscil1_v_layout = QVBoxLayout()
        oscil_h_layout.addWidget(QLabel("Oscillation "))

        oscil2_v_layout = QVBoxLayout()
        # oscil2_label = QLabel(" to ")
        self.oscil2_data = QLabel(empty_str)
        # oscil2_v_layout.addWidget(oscil2_label)
        oscil2_v_layout.addWidget(self.oscil2_data)

        oscil_h_layout.addLayout(oscil1_v_layout)
        oscil_h_layout.addLayout(oscil2_v_layout)
        scan_v_layout.addLayout(oscil_h_layout)

        e_time_label = QLabel("Exposure Time")
        self.e_time_data = QLabel(empty_str)
        e_time_hbox = QHBoxLayout()
        e_time_hbox.addWidget(e_time_label)
        e_time_hbox.addWidget(self.e_time_data)
        scan_v_layout.addLayout(e_time_hbox)

        scan_v_layout.addWidget(QLabel("  "))
        strn_sp_label = QLabel("Strong Spots")
        self.strn_sp_data = QLabel(empty_str)
        strn_hbox = QHBoxLayout()
        strn_hbox.addWidget(strn_sp_label)
        strn_hbox.addWidget(self.strn_sp_data)
        scan_v_layout.addLayout(strn_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        indx_sp_label = QLabel("Indexed Spots")
        self.indx_sp_data = QLabel(empty_str)
        indx_hbox = QHBoxLayout()
        indx_hbox.addWidget(indx_sp_label)
        indx_hbox.addWidget(self.indx_sp_data)
        scan_v_layout.addLayout(indx_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        refn_sp_label = QLabel("Refined Spots")
        self.refn_sp_data = QLabel(empty_str)
        refn_hbox = QHBoxLayout()
        refn_hbox.addWidget(refn_sp_label)
        refn_hbox.addWidget(self.refn_sp_data)
        scan_v_layout.addLayout(refn_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        itgr_prf_label = QLabel("Prof int Spots")
        self.itgr_prf_data = QLabel(empty_str)
        itgr_prf_hbox = QHBoxLayout()
        itgr_prf_hbox.addWidget(itgr_prf_label)
        itgr_prf_hbox.addWidget(self.itgr_prf_data)
        scan_v_layout.addLayout(itgr_prf_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        itgr_sum_label = QLabel("Sum int Spots")
        self.itgr_sum_data = QLabel(empty_str)
        itgr_sum_hbox = QHBoxLayout()
        itgr_sum_hbox.addWidget(itgr_sum_label)
        itgr_sum_hbox.addWidget(self.itgr_sum_data)
        scan_v_layout.addLayout(itgr_sum_hbox)

        scan_v_layout.addStretch()
        scan_group.setLayout(scan_v_layout)

        detec_group = QGroupBox(" Detector ")
        detec_v_layout = QVBoxLayout()
        detec_v_layout.addLayout(get_spacebox(160))

        # detec_v_layout.addWidget(QLabel("  "))
        d_dist_label = QLabel(" Distance (mm)")

        self.d_dist_data = QLabel(empty_str)
        d_dist_hbox = QHBoxLayout()
        d_dist_hbox.addWidget(d_dist_label)
        d_dist_hbox.addWidget(self.d_dist_data)
        detec_v_layout.addLayout(d_dist_hbox)

        # detec_v_layout.addWidget(QLabel("  "))
        n_pans_label = QLabel(" Number of Panels ")
        self.n_pans_data = QLabel(empty_str)
        n_pans_hbox = QHBoxLayout()
        n_pans_hbox.addWidget(n_pans_label)
        n_pans_hbox.addWidget(self.n_pans_data)
        detec_v_layout.addLayout(n_pans_hbox)

        # detec_v_layout.addWidget(QLabel("  "))
        gain_label = QLabel(" Gain ")
        self.gain_data = QLabel(empty_str)
        gain_hbox = QHBoxLayout()
        gain_hbox.addWidget(gain_label)
        gain_hbox.addWidget(self.gain_data)
        detec_v_layout.addLayout(gain_hbox)

        # detec_v_layout.addWidget(QLabel("  "))
        max_res_label = QLabel(" Max res (" + u"\u212B" + ")")
        self.max_res_data = QLabel(empty_str)
        max_res_hbox = QHBoxLayout()
        max_res_hbox.addWidget(max_res_label)
        max_res_hbox.addWidget(self.max_res_data)
        detec_v_layout.addLayout(max_res_hbox)

        detec_v_layout.addWidget(QLabel("  "))
        pix_size_label = QLabel(" Pixel Size ")
        detec_v_layout.addWidget(pix_size_label)

        px_h_layout = QHBoxLayout()

        px_x_v_layout = QVBoxLayout()
        x_px_size_label = QLabel(" X (mm)")
        self.x_px_size_data = QLabel(empty_str)
        px_x_v_layout.addWidget(x_px_size_label)
        px_x_v_layout.addWidget(self.x_px_size_data)

        px_y_v_layout = QVBoxLayout()
        y_px_size_label = QLabel(" Y (mm)")
        self.y_px_size_data = QLabel(empty_str)
        px_y_v_layout.addWidget(y_px_size_label)
        px_y_v_layout.addWidget(self.y_px_size_data)

        px_h_layout.addLayout(px_x_v_layout)
        px_h_layout.addLayout(px_y_v_layout)

        detec_v_layout.addLayout(px_h_layout)

        # detec_v_layout.addWidget(QLabel("  "))
        # detec_v_layout.addStretch()
        detec_group.setLayout(detec_v_layout)

        left_big_box = QHBoxLayout()
        left_big_box.addWidget(beam_group)
        left_big_box.addWidget(cell_group)
        left_big_box.addStretch()

        right_big_box = QHBoxLayout()
        right_big_box.addWidget(detec_group)
        right_big_box.addWidget(scan_group)
        right_big_box.addStretch()

        inner_main_h_box = QVBoxLayout()
        inner_main_h_box.addLayout(left_big_box)
        inner_main_h_box.addLayout(right_big_box)

        self.my_json_path = None
        self.my_pikl_path = None

        self.update_data(exp_json_path=self.my_json_path,
                         refl_pikl_path=self.my_pikl_path)

        self.my_scrollable = QScrollArea()
        tmp_widget = QWidget()
        tmp_widget.setLayout(inner_main_h_box)
        self.my_scrollable.setWidget(tmp_widget)

        main_v_box = QVBoxLayout()
        main_v_box.addWidget(self.my_scrollable)

        self.setLayout(main_v_box)
예제 #12
0
 def setupUi(self):
     """create all other widgets
     we could make the scene view the central widget but I did
     not figure out how to correctly draw the background with
     QGraphicsView/QGraphicsScene.
     QGraphicsView.drawBackground always wants a pixmap
     for a huge rect like 4000x3000 where my screen only has
     1920x1200"""
     # pylint: disable=too-many-statements
     self.setObjectName("MainWindow")
     centralWidget = QWidget()
     self.centralView = FittingView()
     layout = QGridLayout(centralWidget)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget(self.centralView)
     self.setCentralWidget(centralWidget)
     self.centralView.setFocusPolicy(Qt.StrongFocus)
     self.background = None  # just for pylint
     self.windTileset = Tileset(Internal.Preferences.windTilesetName)
     self.adjustMainView()
     self.actionScoreGame = self.kajonggAction("scoreGame", "draw-freehand",
                                               self.scoringScene, Qt.Key_C)
     self.actionPlayGame = self.kajonggAction("play", "arrow-right",
                                              self.playGame, Qt.Key_N)
     self.actionAbortGame = self.kajonggAction("abort", "dialog-close",
                                               self.abortAction, Qt.Key_W)
     self.actionAbortGame.setEnabled(False)
     self.actionQuit = self.kajonggAction("quit", "application-exit",
                                          self.close, Qt.Key_Q)
     self.actionPlayers = self.kajonggAction("players", "im-user",
                                             self.slotPlayers)
     self.actionRulesets = self.kajonggAction("rulesets",
                                              "games-kajongg-law",
                                              self.slotRulesets)
     self.actionChat = self._kajonggToggleAction("chat",
                                                 "call-start",
                                                 shortcut=Qt.Key_H,
                                                 actionData=ChatWindow)
     self.actionChat.setEnabled(False)
     self.actionAngle = self.kajonggAction("angle", "object-rotate-left",
                                           self.changeAngle, Qt.Key_G)
     self.actionAngle.setEnabled(False)
     self.actionScoreTable = self._kajonggToggleAction(
         "scoreTable",
         "format-list-ordered",
         Qt.Key_T,
         actionData=ScoreTable)
     self.actionScoreTable.setEnabled(False)
     self.actionExplain = self._kajonggToggleAction(
         "explain",
         "applications-education",
         Qt.Key_E,
         actionData=ExplainView)
     self.actionExplain.setEnabled(False)
     self.actionFullscreen = self._kajonggToggleAction("fullscreen",
                                                       "view-fullscreen",
                                                       shortcut=Qt.Key_F +
                                                       Qt.ShiftModifier)
     self.actionFullscreen.toggled.connect(self.fullScreen)
     self.actionAutoPlay = self.kajonggAction("demoMode",
                                              "arrow-right-double", None,
                                              Qt.Key_D)
     self.actionAutoPlay.setCheckable(True)
     self.actionAutoPlay.setEnabled(True)
     self.actionAutoPlay.toggled.connect(self._toggleDemoMode)
     self.actionAutoPlay.setChecked(Internal.autoPlay)
     QMetaObject.connectSlotsByName(self)
예제 #13
0
    def __init__(self):
        super(MainWidget, self).__init__()

        self.my_pop = None  # Any child popup windows. Only bravais_table ATM
        self.storage_path = sys_arg.directory

        refresh_gui = False

        # Load the previous state of DUI, if present
        dui_files_path = os.path.join(self.storage_path, "dui_files")

        if os.path.isfile(os.path.join(dui_files_path, "bkp.pickle")):
            try:
                self.idials_runner = load_previous_state(dui_files_path)

            except Exception as e:
                # Something went wrong - tell the user then close
                msg = traceback.format_exc()
                logger.error("ERROR LOADING PREVIOUS DATA:\n%s", msg)
                raise_from(DUIDataLoadingError(msg), e)

            refresh_gui = True
        else:
            # No dui_files path - start with a fresh state
            if not os.path.isdir(dui_files_path):
                os.mkdir(dui_files_path)

            self.idials_runner = Runner()

        self.gui2_log = {"pairs_list": []}

        self.cli_tree_output = TreeShow()
        self.cli_tree_output(self.idials_runner)

        self.cur_html = None
        self.cur_pick = None
        self.cur_json = None
        self.cur_log = None
        self.cur_cmd_name = "None"

        main_box = QVBoxLayout()

        self.centre_par_widget = ControlWidget()
        self.centre_par_widget.pass_sys_arg_object_to_import(sys_arg)
        self.stop_run_retry = StopRunRetry()
        self.tree_out = TreeNavWidget()

        left_control_box = QHBoxLayout()

        left_top_control_box = QVBoxLayout()
        left_top_control_box.addWidget(self.centre_par_widget)
        left_top_control_box.addStretch()
        left_control_box.addLayout(left_top_control_box)

        centre_control_box = QVBoxLayout()

        v_control_splitter = QSplitter()
        v_control_splitter.setOrientation(Qt.Vertical)
        v_control_splitter.addWidget(self.tree_out)
        v_control_splitter.addWidget(self.centre_par_widget.step_param_widg)

        centre_control_box.addWidget(v_control_splitter)
        centre_control_box.addWidget(self.stop_run_retry)
        left_control_box.addLayout(centre_control_box)

        dummy_left_widget = QWidget()
        dummy_h_layout = QHBoxLayout()
        dummy_h_layout.addLayout(left_control_box)
        dummy_left_widget.setLayout(dummy_h_layout)
        dummy_left_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        h_main_splitter = QSplitter()
        h_main_splitter.setOrientation(Qt.Horizontal)
        h_main_splitter.addWidget(dummy_left_widget)

        self.cli_out = CliOutView()
        self.web_view = WebTab()
        self.img_view = MyImgWin()
        self.ext_view = OuterCaller()
        self.info_widget = InfoWidget()

        self.output_info_tabs = QTabWidget()
        self.output_info_tabs.addTab(self.img_view, "Image")
        self.output_info_tabs.addTab(self.cli_out, "Log")
        self.output_info_tabs.addTab(self.web_view, "Report")
        self.output_info_tabs.addTab(self.ext_view, "Tools")
        self.output_info_tabs.addTab(self.info_widget, "Experiment")

        self.view_tab_num = 0
        self.output_info_tabs.currentChanged.connect(self.tab_changed)

        self.img_view.mask_applied.connect(self.pop_mask_list)
        self.img_view.predic_changed.connect(self.tab_changed)
        self.img_view.bc_applied.connect(self.pop_b_centr_coord)

        self.img_view.new_pars_applied.connect(self.pass_parmams)

        # self.ext_view.pass_parmam_lst.connect(self.pass_parmams)

        self.centre_par_widget.finished_masking.connect(self.img_view.unchec_my_mask)
        self.centre_par_widget.click_mask.connect(self.img_view.chec_my_mask)
        self.centre_par_widget.finished_b_centr.connect(self.img_view.unchec_b_centr)
        self.centre_par_widget.click_b_centr.connect(self.img_view.chec_b_centr)

        v_info_splitter = QSplitter()
        v_info_splitter.setOrientation(Qt.Vertical)
        v_info_splitter.addWidget(self.output_info_tabs)

        h_main_splitter.addWidget(v_info_splitter)

        main_box.addWidget(h_main_splitter)

        self.txt_bar = Text_w_Bar()
        main_box.addWidget(self.txt_bar)

        self.connect_all()

        self.custom_thread = CommandThread()
        self.custom_thread.finished.connect(self.update_after_finished)
        self.custom_thread.str_fail_signal.connect(self.after_failed)
        self.custom_thread.str_print_signal.connect(self.cli_out.add_txt)
        self.custom_thread.str_print_signal.connect(self.txt_bar.setText)

        self.custom_thread.busy_box_on.connect(self.pop_busy_box)
        self.custom_thread.busy_box_off.connect(self.close_busy_box)

        self.main_widget = QWidget()
        self.main_widget.setLayout(main_box)
        self.setCentralWidget(self.main_widget)

        self.setWindowTitle("CCP4 DUI - {}: {}".format(__version__,
                dui_files_path))
        self.setWindowIcon(QIcon(self.stop_run_retry.dials_logo_path))

        self.just_reindexed = False
        self.user_stoped = False
        self.reconnect_when_ready()

        self.my_pop = None

        if refresh_gui:
            self.refresh_my_gui()