Beispiel #1
0
    def _layout_indicators(self, indicators):
        subframes = []
        ind_vlayout = QVBoxLayout()

        for line in indicators:
            hboxlayout = QHBoxLayout()
            hboxlayout.addStretch()
            hboxlayout.setAlignment(Qt.AlignTop)

            for ind in line[1:]:

                if type(ind) == list:
                    deeper_layout, deeper_subframes = self._layout_indicators(
                        ind)
                    subframes += deeper_subframes
                    hboxlayout.addLayout(deeper_layout)
                else:
                    hboxlayout.addWidget(ind)

            hboxlayout.addStretch()
            s = SubFrame(line[0], hboxlayout, self)
            subframes.append(s)

            ind_vlayout.addWidget(s)

        return ind_vlayout, subframes
Beispiel #2
0
    def __init__(self, mainWindow):
        super(FolderBrowser, self).__init__()
        self.mainWindow = mainWindow

        self.config = fileUtils.loadConfig()
        self.movieFiles = []

        mainlayout = QVBoxLayout(self)
        mainlayout.setContentsMargins(0, 0, 0, 0)

        buttonlayout = QHBoxLayout()
        buttonlayout.setAlignment(Qt.AlignLeft)
        buttonlayout.setContentsMargins(0, 0, 0, 0)

        mainlayout.addLayout(buttonlayout)

        addFolderBtn = customWidgets.IconButton(
            fileUtils.getIcon("addFolder.png"), "Add Folder", size=40)
        removeFolderBtn = customWidgets.IconButton(
            fileUtils.getIcon("removeFolder.png"), "Remove Folder", size=40)

        addFolderBtn.clicked.connect(self.addFolderAction)
        removeFolderBtn.clicked.connect(self.removeFolderAction)

        buttonlayout.addWidget(addFolderBtn)
        buttonlayout.addWidget(removeFolderBtn)

        self.folderList = FolderList(self)
        if "folders" in self.config:
            self.folderList.refresh()

        mainlayout.addWidget(self.folderList)

        self.folderList.itemClicked.connect(self.getFiles)
Beispiel #3
0
    def __init__(self,title,parent,right_layout=None):
        super(SubTitleWidget,self).__init__(parent)

        self.title = QLabel()
        self.title.setObjectName("subtitle")
        self.title.setScaledContents(True)
        self.set_title(title)

        hlayout = QHBoxLayout()
        hlayout.setAlignment(Qt.AlignTop)
        # hlayout.addWidget(TitleBox(self))
        hlayout.addWidget(self.title)
        hlayout.addStretch()

        if right_layout:
            if isinstance(right_layout,QLayout):
                hlayout.addLayout(right_layout)
            else:
                hlayout.addWidget(right_layout)

        # hlayout.setStretch(1,1)

        top_layout = QVBoxLayout()
        top_layout.addLayout(hlayout)
        top_layout.addSpacing(10)
        top_layout.setContentsMargins(0,0,0,0)

        self.setLayout(top_layout)
        self.setContentsMargins(0,0,0,0)
Beispiel #4
0
    def __init__(self,title,parent,right_layout=None):
        super(TitleWidget,self).__init__(parent)

        self.modified_flag = False

        self.title_label = QLabel()
        self.title_label.setObjectName("TitleWidgetLabel") # For QSS styling
        self.set_title(title)

        hlayout = QHBoxLayout()
        hlayout.setAlignment(Qt.AlignVCenter)
        hlayout.addWidget(TitleBox(self,self.title_label),0,Qt.AlignVCenter)
        hlayout.addWidget(self.title_label,1,Qt.AlignVCenter)

        if right_layout:
            if isinstance(right_layout,QLayout):
                hlayout.addLayout(right_layout)
            else:
                hlayout.addWidget(right_layout)

        # top_layout = QVBoxLayout( )
        # top_layout.addLayout(hlayout)
        # top_layout.addSpacing(20)
        hlayout.setContentsMargins(10,0,10,0)

        self.setLayout(hlayout)
Beispiel #5
0
    def __init__(self):
        super(ReplaceTool, self).__init__()

        self.setWindowFlags(Qt.WindowStaysOnTopHint)
        self.setWindowTitle('Replace Tool')
        self.setFixedHeight(100)
        self.setFixedWidth(320)

        lyt_main = QVBoxLayout()

        lbl_find = QLabel('Find:')
        lbl_find.setFixedWidth(55)

        self.ledit_find = QLineEdit()

        lbl_replace = QLabel('Replace:')
        lbl_replace.setFixedWidth(55)

        self.ledit_replace = QLineEdit()

        reg_ex = QRegExp("[a-zA-Z_]+")
        text_validator = QRegExpValidator(reg_ex, self.ledit_find)
        self.ledit_find.setValidator(text_validator)
        self.ledit_replace.setValidator(text_validator)

        lyt_find = QHBoxLayout()
        lyt_find.addWidget(lbl_find)
        lyt_find.addWidget(self.ledit_find)

        lyt_main.addLayout(lyt_find)

        lyt_replace = QHBoxLayout()
        lyt_replace.addWidget(lbl_replace)
        lyt_replace.addWidget(self.ledit_replace)

        lyt_main.addLayout(lyt_replace)

        btn_submit = QPushButton('Submit')
        btn_submit.setFixedHeight(20)
        btn_submit.setFixedWidth(55)

        lyt_submit_button = QHBoxLayout()
        lyt_submit_button.setAlignment(Qt.AlignRight)
        lyt_submit_button.addWidget(btn_submit)

        lyt_main.addLayout(lyt_submit_button)

        self.setLayout(lyt_main)

        btn_submit.clicked.connect(self.submit)
Beispiel #6
0
 def __init__(self, main_analysis_module, main_analysis_window_module, feature_extractor_dict, parent_window):
     QWidget.__init__(self)
     
     self.analysis_dict = main_analysis_module.analysis_dict
     self.analysis_structured_dict = main_analysis_module.analysis_structured_dict
     self.ordered_analysis_keys = self.analysis_dict.keys()
     self.ordered_analysis_keys.sort()
     self.analysis_window_dict = main_analysis_window_module.analysis_window_dict
     self.feature_extractor_dict = feature_extractor_dict
     self.parent_window = parent_window
     self.setAcceptDrops(True)
     
     # Create a help instance
     self.help_instance = helpForWindow()
     
     # Make one big outer layout
     layout = QHBoxLayout()
     self.setLayout(layout)
     
     # just create the param frame so I have it available to reference when creating the left frame
     qpframe = self.QParamFrameClass(self)
     
     # Create the left frame
     # Put it in a widget so I can control it's size.
     qlframe = self.QLeftFrameClass(qpframe, self)
     qlwidget = QWidget()
     layout.addWidget(qlwidget)
     layout.setAlignment(qlwidget, Qt.AlignTop)
     qlwidget.setLayout(qlframe)
     qlwidget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     self.lframe = qlframe
     
     # Create the right hand frame frame. This has the list of defining parameters plus a popup list of report names
     # Initially there isn't much in the parameter list.
     # Put it in a widget so I can control the size.
     qpwidget = QWidget()
     qpwidget.setMinimumWidth(400)
     layout.addWidget(qpwidget)
     self.right_pane = QScroller(qpframe)
     qpwidget.setLayout(self.right_pane)
     
     # Display some info about the current running environment.
     print sys.version
     print "am I running in 64 bit?"
     print("%x" % sys.maxsize, sys.maxsize > 2 ** 32)
Beispiel #7
0
 def _buildGUI(self):
     '''
     Construct the GUI widgets and layouts.
     '''
     centerWidget = QWidget()
     self._window.setCentralWidget(centerWidget)
     
     worldLayout = QHBoxLayout()
     worldLayout.addWidget(self._worldWidget)
     grpBx = QGroupBox("2D World")
     grpBx.setLayout(worldLayout)
     grpBx.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     
     ctrlPan = self._buildControlPanel()
     layout = QHBoxLayout()
     layout.addWidget(ctrlPan)
     layout.addWidget(grpBx)
     layout.setAlignment(ctrlPan, Qt.AlignLeft | Qt.AlignTop)
     centerWidget.setLayout(layout)
Beispiel #8
0
 def __init__(self, display_text, todo, arg_dict, help_instance = None, max_field_size = None):
     super(qButtonWithArgumentsClass, self).__init__()
     self.todo = todo
     self.setContentsMargins(1, 1, 1, 1)
     newframe = QHBoxLayout()
     self.setLayout(newframe)
     newframe.setSpacing(1)
     newframe.setContentsMargins(1, 1, 1, 1)
     
     new_but = QPushButton(display_text)
     new_but.setContentsMargins(1, 1, 1, 1)
     new_but.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     new_but.setFont(regular_font)
     new_but.setAutoDefault(False)
     new_but.setDefault(False)
     newframe.addWidget(new_but)
     new_but.clicked.connect(self.doit)
     self.arg_hotfields = []
     for k in sorted(arg_dict.keys()):
         if isinstance(arg_dict[k], list):
             the_list = arg_dict[k]
             if len(the_list) == 0:
                 qe = qHotField(k, str, "", the_list, pos = "top", max_size = max_field_size)
             else:
                 qe = qHotField(k, type(arg_dict[k][0]), arg_dict[k][0], the_list, pos = "top", max_size = max_field_size)
         else:
             qe = qHotField(k, type(arg_dict[k]), arg_dict[k], pos = "top", max_size = max_field_size)
         newframe.addWidget(qe)
         newframe.setAlignment(qe, QtCore.Qt.AlignLeft)
         self.arg_hotfields.append(qe)
     newframe.addStretch()
     if hasattr(todo, "help_text"):
         if (help_instance == None):
             print "No help instance specified."
         else:
             help_button_widget = help_instance.create_button(display_text, todo.help_text)
             newframe.addWidget(help_button_widget)
             QtGui.QToolTip.setFont(regular_font)
             self.setToolTip(todo.help_text)
Beispiel #9
0
 def add_line(self):
     self.table.cellChanged.disconnect()
     row = self.table.rowCount()
     self.table.setRowCount(row + 1)
     id = str(self.id)
     ck = QCheckBox()
     h = QHBoxLayout()
     h.setAlignment(Qt.AlignCenter)
     h.addWidget(ck)
     w = QWidget()
     w.setLayout(h)
     name = self.faker.name()
     score = str(random.randint(50, 99))
     add = self.faker.address()
     self.table.setItem(row, 0, QTableWidgetItem(id))
     self.table.setCellWidget(row, 1, w)
     self.table.setItem(row, 2, QTableWidgetItem(name))
     self.table.setItem(row, 3, QTableWidgetItem(score))
     self.table.setItem(row, 4, QTableWidgetItem(add))
     self.id += 1
     self.lines.append([id, ck, name, score, add])
     self.settext(u'自动生成随机一行数据!,checkbox设置为居中显示')
     self.table.cellChanged.connect(self.cellchange)
Beispiel #10
0
    def __init__(self, mainWindow):
        super(PosterView, self).__init__()
        self.mainWindow = mainWindow

        mainlayout = QVBoxLayout(self)
        mainlayout.setContentsMargins(0, 0, 0, 0)

        toolbarLayout = QHBoxLayout()
        toolbarLayout.setAlignment(Qt.AlignLeft)
        mainlayout.addLayout(toolbarLayout)

        favBtn = QPushButton("Fav")
        favBtn.setMaximumWidth(50)
        editBtn = QPushButton("Edit")
        editBtn.setMaximumWidth(50)

        toolbarLayout.addWidget(favBtn)
        toolbarLayout.addWidget(editBtn)

        self.posterList = PosterList()
        mainlayout.addWidget(self.posterList)

        favBtn.clicked.connect(self.posterList.setFavorited)
        editBtn.clicked.connect(self.posterList.editMovie)
Beispiel #11
0
    def __init__(self, tag, text, parent, handler, icon=None):
        """Constructs a DropPanel

           tag
               A string associated with this DropPanel

           text
               The text displayed on this DropPanel

           parent
               The Qt GUI parent of this panel

           handler
               The datatree index list and tag will be passed to this
               function.

           icon
               Optional QIcon to display on this panel.
        """
        super(DropPanel, self).__init__(parent)

        self.setAcceptDrops(True)
        self.handler = handler
        self.tag = tag
        self.setPalette(QColor(0, 0, 0, 0))

        layout = QHBoxLayout(self)
        layout.setAlignment(Qt.AlignCenter)
        if icon is not None:
            label = QLabel("", parent=self)
            label.setPixmap(icon)
            layout.addWidget(label)
            layout.addSpacing(5)
        textlabel = QLabel(text)
        textlabel.setStyleSheet("QLabel { color : white; }")
        layout.addWidget(textlabel)
Beispiel #12
0
    def __init__(self, tag, text, parent, handler, icon = None):
        """Constructs a DropPanel

           tag
               A string associated with this DropPanel

           text
               The text displayed on this DropPanel

           parent
               The Qt GUI parent of this panel

           handler
               The datatree index list and tag will be passed to this
               function.

           icon
               Optional QIcon to display on this panel.
        """
        super(DropPanel, self).__init__(parent)

        self.setAcceptDrops(True)
        self.handler = handler
        self.tag = tag
        self.setPalette(QColor(0,0,0,0))

        layout = QHBoxLayout(self)
        layout.setAlignment(Qt.AlignCenter)
        if icon is not None:
            label = QLabel("", parent = self)
            label.setPixmap(icon)
            layout.addWidget(label)
            layout.addSpacing(5)
        textlabel = QLabel(text)
        textlabel.setStyleSheet("QLabel { color : white; }");
        layout.addWidget(textlabel)
Beispiel #13
0
class RadioApp(QWidget):
    def __init__(self):
        super().__init__()
        self.edit = False

        self.left_dock_create()
        self.middle_dock_create()
        self.right_dock_create()
        self.slotans_create()

        self.box = QHBoxLayout()
        self.box.addLayout(self.volbalayout)
        self.box.addLayout(self.middlelayout)
        self.box.addLayout(self.rightlayout)

        self.mainlayout = QVBoxLayout()
        self.mainlayout.addLayout(self.box)
        self.setLayout(self.mainlayout)

    def left_dock_create(self):
        self.statlabel = QLabel("RSSI: --")
        self.logolabel = QLabel()
        self.logolabel.setPixmap(
            QPixmap(os.path.join(script_path, "../assets/logo.png")))
        self.statlabel.setFont(QFont("DejaVu Sans", 12))

        self.btnvolba = []
        for i in range(1, 5):
            self.btnvolba.append(QPushButton("Voľba {}".format(i)))

        self.presetaddbtn = QPushButton()
        self.presetaddbtn.setIcon(QIcon(QPixmap("../assets/add.png")))

        self.volbalayout = QVBoxLayout()
        self.volbalayout.addWidget(self.logolabel)
        self.volbalayout.addWidget(self.statlabel)
        for btn in self.btnvolba:
            self.volbalayout.addWidget(btn)
        self.volbalayout.addWidget(self.presetaddbtn)

    def middle_dock_create(self):
        self.frekv = QLabel()
        self.frekv.setFont(QFont("DejaVu Sans", 26))
        self.write_frekv()

        self.btnstepleft = QPushButton("<")
        self.btnseekdown = QPushButton("<<")
        self.btnseekup = QPushButton(">>")
        self.btnstepright = QPushButton(">")

        self.laybtnmv = QHBoxLayout()
        self.laybtnmv.addWidget(self.btnseekdown)
        self.laybtnmv.addWidget(self.btnstepleft)
        self.laybtnmv.addWidget(self.btnstepright)
        self.laybtnmv.addWidget(self.btnseekup)

        self.labelrdsdt = QLabel("RDS")
        self.labelrdsdt.setFont(QFont("DejaVu Sans", 12))

        self.frekvlayout = QHBoxLayout()
        self.frekvlayout.addWidget(self.frekv)
        self.frekvlayout.setAlignment(Qt.AlignCenter)

        self.middlelayout = QVBoxLayout()
        self.middlelayout.addLayout(self.frekvlayout)
        self.middlelayout.addLayout(self.laybtnmv)
        self.middlelayout.addWidget(self.labelrdsdt)

    def right_dock_create(self):
        self.btnonoff = QPushButton("Reset")
        self.slidvol = QSlider(Qt.Vertical)
        self.slidvol.setMinimum(0)
        self.slidvol.setMaximum(100)
        self.slidvol.setValue(50)
        self.labspeaker = QLabel()
        self.labspeaker.setPixmap(
            QPixmap(os.path.join(script_path, "../assets/speaker.png")))
        self.sndvolumelabel = QLabel()

        self.rightlayout = QVBoxLayout()
        self.rightlayout.addWidget(self.btnonoff)
        self.rightlayout.addWidget(self.slidvol)
        self.rightlayout.addWidget(self.sndvolumelabel)
        self.rightlayout.addWidget(self.labspeaker)

    def slotans_create(self):
        self.slidvol.valueChanged.connect(self.set_radiovolume)
        self.btnstepleft.clicked.connect(lambda: self.step_frekv("d"))
        self.btnstepright.clicked.connect(lambda: self.step_frekv("u"))
        self.btnseekdown.clicked.connect(lambda: self.set_seek("d"))
        self.btnseekup.clicked.connect(lambda: self.set_seek("u"))

        self.presetaddbtn.clicked.connect(self.preset_editmode)
        self.btnonoff.clicked.connect(self.reset_radio)
        for btn in self.btnvolba:
            btn.clicked.connect(self.preset_choose)
        self.timerrssi = QTimer()
        self.timerrssi.timeout.connect(self.write_stats)
        self.timerrssi.start(3000)  # ms

    def reset_radio(self):
        dev_radio.shutdown()
        dev_radio.poweron()

    def preset_editmode(self):
        if self.edit == True:
            # Chceme sa vrátiť do normálneho režimu -> zvrátime editačný
            for btn in self.btnvolba:
                btn.setStyleSheet("")
                btn.clicked.disconnect()
                btn.clicked.connect(self.preset_choose)
        else:
            # Vstupujeme do editačného režimu
            for btn in self.btnvolba:
                btn.setStyleSheet("background-color: #30f030;")
                btn.clicked.disconnect()
                btn.clicked.connect(self.preset_set)
        self.edit = not self.edit

    def preset_set(self):
        button = self.sender()
        if isinstance(button, QPushButton):
            button.setText("{:.2f}".format(dev_radio.getfrequency() / 100))
            self.preset_editmode()

    def preset_choose(self):
        button = self.sender()
        if isinstance(button, QPushButton):
            try:
                frekv = int(float(button.text()) * 100)
            except ValueError:
                return
            dev_radio.setfrequency(frekv)
            self.write_frekv()

    def preset_save(self):
        with open("preset.txt", mode="w") as fw:
            for btn in self.btnvolba:
                try:
                    fw.write("{},".format(int(float(btn.text()) * 100)))
                except ValueError:
                    fw.write(" ,")

    def preset_restore(self):
        try:
            fr = open("preset.txt", mode="r")
            pres_list = fr.read().split(",")
        except FileNotFoundError:
            return

        fr.close()
        if len(pres_list) - 1 < len(self.btnvolba):
            print("Chyba: Zoznam predvolieb je krátky")
            return

        for i, btn in enumerate(self.btnvolba):
            try:
                btn.setText("{:.2f}".format(int(pres_list[i]) / 100))
            except ValueError:
                continue

    def set_seek(self, direction):
        if direction == "u":
            dev_radio.seekup()
        elif direction == "d":
            dev_radio.seekdown()
        self.write_frekv()

    def step_frekv(self, direction):
        curr_frekv = dev_radio.getfrequency()
        if direction == "u":
            curr_frekv += 10
            if curr_frekv > dev_radio.freqhigh:
                curr_frekv = dev_radio.freqlow
        elif direction == "d":
            curr_frekv -= 10
            if curr_frekv < dev_radio.freqlow:
                curr_frekv = dev_radio.freqhigh
        dev_radio.setfrequency(curr_frekv)
        self.write_frekv()

    def write_frekv(self):
        self.frekv.setText("<b>{:.2f} MHz</b>".format(
            dev_radio.getfrequency() / 100))

    def write_stats(self):
        self.statlabel.setText("<b>RSSI: {}</b>".format(dev_radio.getrssi()))

    def set_radiovolume(self):
        vol_percent = self.slidvol.value()
        self.sndvolumelabel.setText("{}%".format(vol_percent))
        new_volume = int(map_range(vol_percent, 0, 100, 0, 15))
        dev_radio.setvolume(new_volume)

    def rds_psshow(self, station):
        print("Stanica: {}".format(station))

    def rds_txtshow(self, text):
        print("Text: {}".format(text))

    def rds_tmshow(self, hodiny, minuty):
        print("{}:{}".format(hodiny, minuty))
    def __init__ (self, lcvsa_dict, parent = None):
        QDialog.__init__(self)
        
        if isinstance(lcvsa_dict, dict):
            self._lcvsa_dict = lcvsa_dict
        else:
            self._lcvsa_dict = {lcvsa_dict.__class__.__name__+ "_1": lcvsa_dict}
        self._lcvsa = self._lcvsa_dict[self._lcvsa_dict.keys()[0]]

        # Get the various color maps from pylab        
        self.color_maps=[m for m in pylab.cm.datad if not m.endswith("_r")]
        self.color_maps += ["AA_traditional_"]
        self.color_maps.sort()

        self.mplwin_list = [] # The list of matplotlib windows
        
        # Create the major frames.
        main_frame = QHBoxLayout()

        self._explorer_windows = []
        leftWidget = QWidget()
        leftWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setLayout(main_frame)
        main_frame.setContentsMargins(5, 5, 5, 5)
        left_frame = QVBoxLayout()
        left_frame.setContentsMargins(1, 1, 1, 1)
        left_frame.setSpacing(5)
        main_frame.addWidget(leftWidget)
        main_frame.setAlignment(leftWidget, QtCore.Qt.AlignTop)
        leftWidget.setLayout(left_frame)
        leftWidget.setMinimumSize(600, 750)
        leftWidget.setMaximumWidth(750)

        
        right_frame = qNotebook() # The right frame holds a qNotebook
        main_frame.addLayout(right_frame)
        self._lframe = left_frame
        self._main_frame = main_frame
        self._rframe = right_frame

        # Put a small frame at the top of the left frame to hold some checkboxes, and a pop list for selecting analyses
        self.top_left_frame = QVBoxLayout()
        left_frame.addLayout(self.top_left_frame)

        # Make the checkboxes
        self.inline = qHotField("Put images in the notebook", bool, False)
        self.top_left_frame.addWidget(self.inline)
        self.show_legends = qHotField("Show legends on charts", bool, True)
        self.top_left_frame.addWidget(self.show_legends)
        self.show_titles = qHotField("Show titles on charts", bool, True)
        self.top_left_frame.addWidget(self.show_titles)
        self.show_tables_in_explorer = qHotField("Show tables in explorer", bool, False)
        self.top_left_frame.addWidget(self.show_tables_in_explorer)

        # Create the popup list that allows the selection of an analysis, for the case in which there are multiple analyses.
        if not isinstance(self._lcvsa, MonteCarloDescriptorClass):
            self.analysis_popup_list = AnalysisSelector(self)
            self.top_left_frame.addWidget(self.analysis_popup_list)

        # create the instance of helpForWindow so we can display help
        self.help_instance = helpForWindow()

        # Make the commandTabWidget that will hold tabs with all of the commands
        self.tabWidget = CommandTabWidget(self.help_instance)
        self._lframe.addWidget(self.tabWidget)
        self.set_up_left_frame() # usually calls make_widgets which adds the commands to the tabs

        # Add the field for executing code.
        self.exec_frame = QHBoxLayout()
        left_frame.addLayout(self.exec_frame)
        qmy_button(self.exec_frame, self.execute_code, "Execute")
        self.code_field = QLineEdit("")
        self.code_field.setMaximumWidth(400)
        self.code_field.returnPressed.connect(self.execute_code)
        self.exec_frame.addWidget(self.code_field)
        # left_frame.addStretch()
        main_frame.setStretch(0,1)
        main_frame.setStretch(1, 2)
        
        if self._lcvsa.saved_notebook_html != None:
            right_frame.append_text(self._lcvsa.saved_notebook_html)
            # text_doc = self._rframe._teditor.document()
            for imageFileName in self._lcvsa.saved_image_data_dict.keys():
                self._rframe.add_image_data_resource(self._lcvsa.saved_image_data_dict[imageFileName], imageFileName)
            right_frame.image_counter = self._lcvsa.saved_image_counter
                # text_doc.addResources(QTextDocument.ImageResource, QUrl(imageFileName), self._lcvsa.saved_notebook_image_dict[imageFileName])
        else:
            self.gprint("\n<b>Base class is " + self._lcvsa.__class__.__name__ + "\n</b>")
            self.display_analysis_parameters()
class ToolbarWidget(QWidget):
	"""
	ToolbarWidget
	"""

	def __init__(self):
		super(ToolbarWidget, self).__init__()

		# Make sure the widget expands over the whole toolbar
		self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

		# Create main layout that will contain the layouts for each section
		self.mainLayout = QHBoxLayout()
		self.mainLayout.setContentsMargins(0, 0, 0, 0)
		self.mainLayout.setSpacing(0)

		# Layout on the left side
		self.leftLayout = QHBoxLayout()
		self.leftLayout.setContentsMargins(0, 0, 0, 0)
		self.leftLayout.setSpacing(0)
		self.leftLayout.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

		# Layout in the center
		self.centerLayout = QHBoxLayout()
		self.centerLayout.setContentsMargins(0, 0, 0, 0)
		self.centerLayout.setSpacing(0)
		self.centerLayout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)

		# Layout on the right side
		self.rightLayout = QHBoxLayout()
		self.rightLayout.setContentsMargins(0, 0, 0, 0)
		self.rightLayout.setSpacing(0)
		self.rightLayout.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

		self.setLayout(self.mainLayout)

		self.leftWidget = QWidget()
		self.leftWidget.setLayout(self.leftLayout)
		self.centerWidget = QWidget()
		self.centerWidget.setLayout(self.centerLayout)
		self.rightWidget = QWidget()
		self.rightWidget.setLayout(self.rightLayout)

		self.mainLayout.addWidget(self.leftWidget)
		self.mainLayout.addWidget(self.centerWidget)
		self.mainLayout.addWidget(self.rightWidget)

	def setText(self, text):
		self.label.setText(text)

	def addActionLeft(self, action):
		toolButton = CreateFlatButton(action)
		self.addLeftItem(toolButton)

	def addActionCenter(self, action):
		toolButton = CreateFlatButton(action)
		self.addCenterItem(toolButton)

	def addActionRight(self, action):
		toolButton = CreateFlatButton(action)
		self.addRightItem(toolButton)

	def addLeftItem(self, widget):
		self.leftLayout.addWidget(widget)

	def addCenterItem(self, widget):
		self.centerLayout.addWidget(widget)

	def addRightItem(self, widget):
		self.rightLayout.addWidget(widget)
Beispiel #16
0
class ToolbarWidget(QWidget):
    """
	ToolbarWidget
	"""
    def __init__(self):
        super(ToolbarWidget, self).__init__()

        # Make sure the widget expands over the whole toolbar
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # Create main layout that will contain the layouts for each section
        self.mainLayout = QHBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)

        # Layout on the left side
        self.leftLayout = QHBoxLayout()
        self.leftLayout.setContentsMargins(0, 0, 0, 0)
        self.leftLayout.setSpacing(0)
        self.leftLayout.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        # Layout in the center
        self.centerLayout = QHBoxLayout()
        self.centerLayout.setContentsMargins(0, 0, 0, 0)
        self.centerLayout.setSpacing(0)
        self.centerLayout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)

        # Layout on the right side
        self.rightLayout = QHBoxLayout()
        self.rightLayout.setContentsMargins(0, 0, 0, 0)
        self.rightLayout.setSpacing(0)
        self.rightLayout.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.setLayout(self.mainLayout)

        self.leftWidget = QWidget()
        self.leftWidget.setLayout(self.leftLayout)
        self.centerWidget = QWidget()
        self.centerWidget.setLayout(self.centerLayout)
        self.rightWidget = QWidget()
        self.rightWidget.setLayout(self.rightLayout)

        self.mainLayout.addWidget(self.leftWidget)
        self.mainLayout.addWidget(self.centerWidget)
        self.mainLayout.addWidget(self.rightWidget)

    def setText(self, text):
        self.label.setText(text)

    def addActionLeft(self, action):
        toolButton = CreateFlatButton(action)
        self.addLeftItem(toolButton)

    def addActionCenter(self, action):
        toolButton = CreateFlatButton(action)
        self.addCenterItem(toolButton)

    def addActionRight(self, action):
        toolButton = CreateFlatButton(action)
        self.addRightItem(toolButton)

    def addLeftItem(self, widget):
        self.leftLayout.addWidget(widget)

    def addCenterItem(self, widget):
        self.centerLayout.addWidget(widget)

    def addRightItem(self, widget):
        self.rightLayout.addWidget(widget)
class DirectoryDetectWindow(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.setWindowTitle('Directory Detective Tool')
        main_layout = QVBoxLayout()

        path_layout = self._init_path_layout()
        guide_layout = self._init_guide_layout()
        detail_layout = self._init_detail_layout()

        main_layout.addLayout(path_layout)
        main_layout.addLayout(guide_layout)
        main_layout.addLayout(detail_layout)
        self.setLayout(main_layout)
        self.setGeometry(300, 300, 400, 350)
        self._connect()

        self._walk_folder = None
        self._last_path = None
        self.directory_info = None
        self._button_list = list()
        self._last_info = None

    def _init_path_layout(self):
        path_layout = QHBoxLayout()
        self.input_path = QLineEdit(self)
        self.input_path.setFixedHeight(35)
        self.input_path.setPlaceholderText('Type search path here')
        self.button_path = QPushButton('Scan', self)
        self.button_path.setFixedHeight(35)
        self.button_path.setFocus()

        path_layout.addWidget(QLabel('Path:', self))
        path_layout.addWidget(self.input_path, stretch=True)
        path_layout.addWidget(self.button_path)
        return path_layout

    def _init_guide_layout(self):
        self.guide_layout = QHBoxLayout()
        self.guide_layout.setAlignment(Qt.AlignLeft)
        return self.guide_layout

    def refresh_trees(self, store_list, ignore_list):
        self._refresh_key_tree(store_list, ignore_list=ignore_list)
        self._refresh_value_tree(store_list)

    def add_button(self, name, store_list, ignore_list=None):
        button = QPushButton(name)
        button.setFixedSize(60, 35)
        item = (name, button, store_list, ignore_list)
        self._button_list.append(item)
        self.guide_layout.addWidget(button)
        self.refresh_trees(store_list=store_list, ignore_list=ignore_list)
        button.clicked.connect(lambda: self._set_button(item=item))

    def _set_button(self, item):
        index_item = self._button_list.index(item)

        if len(self._button_list) > index_item + 1:
            for name, button, store_list, ignore_list in self._button_list[index_item + 1:]:
                button.setParent(None)

        name, button, store_list, ignore_list = item
        self.refresh_trees(store_list=store_list, ignore_list=ignore_list)

    def _init_detail_layout(self):
        detail_layout = QGridLayout()
        self.key_tree = QTreeWidget()
        self.key_tree.setColumnCount(2)
        self.key_tree.setColumnWidth(0, 200)
        self.key_tree.setHeaderLabels(['Key', 'Size'])

        self.value_tree = QTreeWidget()
        self.value_tree.setColumnCount(2)
        self.value_tree.setColumnWidth(0, 200)
        self.value_tree.setHeaderLabels(['Path', 'Size'])

        detail_layout.setColumnStretch(0, 1)
        detail_layout.setColumnStretch(1, 1)
        detail_layout.addWidget(self.value_tree)
        detail_layout.addWidget(self.key_tree)
        return detail_layout

    def _connect(self):
        self.button_path.clicked.connect(self.button_path_clicked)
        self.key_tree.doubleClicked.connect(self.key_tree_double_clicked)

    def button_path_clicked(self):
        del self._button_list[:]
        for _ in range(self.guide_layout.count()):
            current_item = self.guide_layout.takeAt(0)
            current_item.widget().setParent(None)

        path = unicode.encode(self.input_path.text())
        if self._last_path != path:
            self._walk_folder = walk_folder.run(path=path)

        max_level = 4
        self.directory_info = list(self._walk_folder.get_children_by_level(level=max_level))
        self.add_button('/', self.directory_info)

    def key_tree_double_clicked(self, selected_index=QModelIndex()):
        select_data = selected_index.data()
        ignore_list = [select_data]
        for item in self._button_list[1:]:
            ignore_list.append(item[0])

        store_dict = dict(self._last_info.get_children_by_key(key=select_data, ignore_list=ignore_list).sort_dictionary)
        store_list = list()

        for item in store_dict.values():
            store_list.extend(item['children'])

        store_list = list(set(store_list))
        self.add_button(select_data, store_list or list(), ignore_list=ignore_list)

    def _get_size(self, size):
        return '{} <> {}%'.format(human_size(size), round(size * 100 / self._walk_folder.total_size, 2))

    def _refresh_key_tree(self, directory_info, ignore_list=None):
        info = LabelInfo(make_dictionary_by_classification(directory_info, ignore_list))

        # Clear
        for _ in range(self.key_tree.topLevelItemCount()):
            self.key_tree.takeTopLevelItem(0)

        # Add
        for k, v in info.sort_dictionary:
            tree_widget = QTreeWidgetItem()
            tree_widget.setText(0, k)
            total_size = 0
            for child in v['children']:
                total_size += child.total_size
            tree_widget.setText(1, self._get_size(v[constant.sort_size_name]))
            self.key_tree.addTopLevelItem(tree_widget)
        self._last_info = info

    def _refresh_value_tree(self, directory_info):
        info = sorted(directory_info, key=lambda x: x.total_size, reverse=True)

        # Clear
        for _ in range(self.value_tree.topLevelItemCount()):
            self.value_tree.takeTopLevelItem(0)

        # Add
        for item in info:
            tree_widget = QTreeWidgetItem()
            tree_widget.setText(0, item.part_path)
            tree_widget.setText(1, self._get_size(item.total_size))
            self.value_tree.addTopLevelItem(tree_widget)
class Ui_MainView(QMainWindow):

    gui_methods_sig = Signal(int, )

    def __init__(self, ):
        super(Ui_MainView, self).__init__()

        self.output_folder = os.getcwd()
        self.usr = ''
        self.psw = ''

        self.save_username_checked = False

        self.right_base_layout_v = QtGui.QVBoxLayout()
        self.msgBox = QtGui.QMessageBox()

        self.validations = validate_inputs.validate_controls(
            self
        )  # instance for input validations  and we are passing self to validate class for model updations

    def gifUI(self, gui_slate):

        self.gui = gui_slate
        self.gif_widget = QWidget()
        self.gif_layout = QVBoxLayout()

        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Expanding)
        self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        self.gif_layout.addWidget(self.movie_screen)

        ag_file = "GIF-180704_103026.gif"

        self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(),
                                  self.gif_widget)
        self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        self.movie.setSpeed(75)
        self.movie_screen.setMovie(self.movie)
        #         self.movie_screen.setFixedWidth(500)

        self.gif_widget.setLayout(self.gif_layout)
        self.gui.setCentralWidget(self.gif_widget)
        #         self.gui.addDockWidget(self.gif_widget)
        self.movie.start()
        #         self.movie.setPaused(True)
        self.gif_widget.show()
#         time.sleep(2)
#         self.movie.stop()

    def setupUi(self, gui_slate):

        self.gui = gui_slate
        self.gui.get_option_selected = False
        self.gui.push_option_selected = False
        self.gui.extract_opt_selected = False
        self.gui.compare_opt_selected = False

        #Outer most Main Layout

        self.widget = QWidget()
        self.widget.setMinimumSize(850, 600)

        self.main_layout_h = QHBoxLayout()
        self.main_layout_h.setAlignment(QtCore.Qt.AlignTop)

        self.widget.setLayout(self.main_layout_h)

        self.gui.setCentralWidget(self.widget)

        self.left_base_widget = QWidget()
        #         self.left_base_widget.setMaximumWidth(600)
        #         self.left_base_widget.setMinimumWidth(450)
        #         self.left_base_widget.setMaximumHeight(700)

        self.right_base_widget = QWidget()

        #3 Sub main Layouts

        self.left_base_layout_v = QVBoxLayout()
        #         self.right_base_layout_v = QVBoxLayout()
        self.corner_logo_layout_v = QVBoxLayout()
        self.left_base_layout_v.setAlignment(QtCore.Qt.AlignTop)

        self.right_base_layout_v.setAlignment(QtCore.Qt.AlignTop)

        #Added Widgets and layouts to the outermost layout

        self.main_layout_h.addWidget(self.left_base_widget)
        self.main_layout_h.addWidget(self.right_base_widget)
        self.main_layout_h.addLayout(self.corner_logo_layout_v)

        #         , QtGui.QFont.Normal
        self.grp_heading_font = QtGui.QFont("Verdana", 10)
        self.grp_heading_font.setItalic(True)

        #Radio buttons layout

        self.radio_groupBox = QtGui.QGroupBox()
        self.radio_option_layout_lb_h = QHBoxLayout()

        self.radio_groupBox.setLayout(self.radio_option_layout_lb_h)

        self.radio_groupBox.setMinimumWidth(450)
        self.left_base_layout_v.addWidget(self.radio_groupBox)

        #Credentials layouts

        self.credentials_groupbox = QtGui.QGroupBox("GTAC Credentials")
        self.credentials_groupbox.setFont(self.grp_heading_font)
        self.credentials_layout_lb_v = QVBoxLayout()

        self.username_layout_lb_h = QHBoxLayout()
        self.password_layout_lb_h = QHBoxLayout()
        self.cr_layout_lb_h = QHBoxLayout()
        self.password_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.credentials_layout_lb_v.addLayout(self.username_layout_lb_h)
        self.credentials_layout_lb_v.addLayout(self.password_layout_lb_h)
        self.credentials_layout_lb_v.addLayout(self.cr_layout_lb_h)

        self.credentials_groupbox.setLayout(self.credentials_layout_lb_v)
        self.left_base_layout_v.addWidget(self.credentials_groupbox)
        self.credentials_groupbox.setAlignment(QtCore.Qt.AlignLeft)
        self.credentials_groupbox.hide()

        #IP group box layouts

        self.IP_groupBox = QtGui.QGroupBox("IP Inputs")
        self.IP_groupBox.setFont(self.grp_heading_font)
        self.ip_file_layout_lb_v = QVBoxLayout()

        self.ip_file_select_layout_lb_h = QHBoxLayout()
        self.ip_file_select_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.ip_file_layout_lb_v.addLayout(self.ip_file_select_layout_lb_h)

        self.IP_groupBox.setMaximumHeight(135)
        self.IP_groupBox.setLayout(self.ip_file_layout_lb_v)
        self.left_base_layout_v.addWidget(self.IP_groupBox)

        self.IP_groupBox.hide()

        # Commands  group box selection

        self.Commands_groupBox = QtGui.QGroupBox("Commands Inputs")
        self.Commands_groupBox.setFont(self.grp_heading_font)
        self.commands_label_layout_lb_v = QVBoxLayout()

        self.default_chkbx_layout_lb_h = QHBoxLayout()
        self.commands_file_layout_lb_h = QHBoxLayout()
        self.commands_file_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.commands_custom_box_layout_lb_h = QHBoxLayout()
        self.none_radio_btn_layout_lb_h = QHBoxLayout()

        self.commands_label_layout_lb_v.addLayout(
            self.default_chkbx_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.commands_file_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.commands_custom_box_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.none_radio_btn_layout_lb_h)

        self.Commands_groupBox.setMaximumHeight(225)
        self.Commands_groupBox.setAlignment(QtCore.Qt.AlignLeft)
        self.Commands_groupBox.setLayout(self.commands_label_layout_lb_v)
        self.left_base_layout_v.addWidget(self.Commands_groupBox)

        self.Commands_groupBox.hide()

        # results group box

        self.results_groupBox = QtGui.QGroupBox("Results")
        self.results_groupBox.setFont(self.grp_heading_font)
        self.results_layout_lb_v = QVBoxLayout()

        self.output_layout_lb_h = QHBoxLayout()
        self.output_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)

        self.results_layout_lb_v.addLayout(self.output_layout_lb_h)

        self.results_groupBox.setLayout(self.results_layout_lb_v)
        self.left_base_layout_v.addWidget(self.results_groupBox)

        self.results_groupBox.hide()

        # Go Button

        self.go_btn_layout_lb_h = QHBoxLayout()
        self.left_base_layout_v.addLayout(self.go_btn_layout_lb_h)

        # Right and Left Widget on individual layouts

        self.left_base_widget.setLayout(self.left_base_layout_v)
        self.right_base_widget.setLayout(self.right_base_layout_v)

        #### just to see right base layout

        self.right_base = QtGui.QTextEdit(self.gui)
        self.right_base.setStyleSheet(
            """QToolTip { background-color: #00bfff; color: black; border: black solid 2px  }"""
        )
        self.right_base.setObjectName("IP_Address")
        self.right_base_layout_v.addWidget(self.right_base)
        #         self.right_base.setMaximumHeight(500)
        self.right_base.hide()

        self.snap_gif = QtGui.QLabel(self.gui)
        self.snap_gif.setText("")
        self.snap_gif.setStyleSheet("background-color: None")
        self.snap_gif.setPixmap(QtGui.QPixmap("Capture.png"))
        self.snap_gif.setObjectName("logo_corner")
        self.right_base_layout_v.addWidget(self.snap_gif)

        ######

        self.gui.setWindowTitle('SPEED +  3.0')
        self.gui.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
        self.gui.setAutoFillBackground(True)

        self.corner_logolabel = QtGui.QLabel(self.gui)
        self.corner_logolabel.setText("")
        self.corner_logolabel.setStyleSheet("background-color: None")
        self.corner_logolabel.setPixmap(QtGui.QPixmap(":/logo/ATT-LOGO-2.png"))
        self.corner_logolabel.setObjectName("logo_corner")
        #         self.corner_logo_layout_v.setAlignment(QtCore.Qt.AlignTop)
        self.corner_logo_layout_v.setAlignment(
            int(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight))
        self.corner_logo_layout_v.addWidget(self.corner_logolabel)

        self.msgBox.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
        self.msgBox.setFont(QtGui.QFont("Verdana", 8, QtGui.QFont.Normal))
        self.make_menu()
        ## gif at&t logo
        #         self.movie_screen = QLabel()
        #         self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
        #         self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        #         self.right_base_layout_v.addWidget(self.movie_screen)
        #
        #         ag_file = "C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
        #         self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
        #         self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        #         self.movie.setSpeed(75)
        #         self.movie_screen.setMovie(self.movie)
        #
        #
        #         self.movie.setPaused(True)
        #         self.movie.start()
        #         self.right_base_widget.show()
        #         time.sleep(2)

        ######################### order of the below funtion calls is importnant change them wisely#####################
        self.check_save_username()
        self.create_views()
        self.left_radio_controls()
        self.connect_child_views()

    def make_menu(self):
        self.myMenu = self.gui.menuBar()

        self.file = self.myMenu.addMenu('&File')

        self.file.addAction("&Select Output Folder...",
                            self.select_destination, "Ctrl+O")
        self.file.addAction("&Exit", self.closewindow, "Ctrl+X")

        self.file = self.myMenu.addMenu('&Help')

        self.file.addAction("&About...", self.about_tool, "Ctrl+H")

    def check_save_username(self):
        print("Yo reached save username")
        try:
            f = open('Username.txt', 'r')
            lines = f.readlines()
            if len(lines):
                self.save_username_checked = True
            else:
                self.save_username_checked = False
        except Exception as ex:
            print(ex)

    def select_destination(self, ):

        fld = QtGui.QFileDialog.getExistingDirectory(self.gui,
                                                     'Select Output Folder')
        self.output_folder = str(fld)

    def closewindow(self):
        self.gui.close()

    def about_tool(self):
        abouttool = "Speed + v3.0 \n\nThis tool is useful to fetch, push, extract, compare device configs \n"

        self.msgBox.setText(abouttool)
        self.msgBox.setWindowTitle("About Speed +")
        self.msgBox.show()

    def left_radio_controls(self):

        # ============================    main radio options selection :
        radio_font = QtGui.QFont("Verdana", 10, QtGui.QFont.Normal)

        self.get_radio_option = QtGui.QRadioButton(self.gui)
        self.get_radio_option.setFont(radio_font)
        self.get_radio_option.setText("Get")
        self.radio_option_layout_lb_h.addWidget(self.get_radio_option)

        self.push_radio_option = QtGui.QRadioButton(self.gui)
        self.push_radio_option.setFont(radio_font)
        self.push_radio_option.setText("Push")
        self.radio_option_layout_lb_h.addWidget(self.push_radio_option)

        self.extract_radio_option = QtGui.QRadioButton(self.gui)
        self.extract_radio_option.setFont(radio_font)
        self.extract_radio_option.setText("Extract")
        self.radio_option_layout_lb_h.addWidget(self.extract_radio_option)

        self.compare_radio_option = QtGui.QRadioButton(self.gui)
        self.compare_radio_option.setFont(radio_font)
        self.compare_radio_option.setText("Compare")
        self.radio_option_layout_lb_h.addWidget(self.compare_radio_option)

    def disp_get_options(self):

        self.snap_gif.show()
        self.push_view.hide_push()
        self.excel_view.userOptionextract.hide()
        self.compare_view.main_widget.hide()
        self.get_view.display_get()

    def disp_push_options(self):

        self.snap_gif.show()
        self.get_view.hide_get()
        self.excel_view.userOptionextract.hide()
        self.compare_view.main_widget.hide()
        self.push_view.display_push()
        self.validations.hide_right_common()

    def disp_ext_options(self):

        self.get_view.hide_get()
        self.push_view.hide_push()
        self.compare_view.main_widget.hide()
        self.excel_view.display_excel_portion()
        self.validations.hide_right_common()

    def disp_comp_options(self):

        self.get_view.hide_get()
        self.push_view.hide_push()
        self.excel_view.userOptionextract.hide()
        self.compare_view.display_comapre_portion()
        self.validations.hide_right_common()

    def connect_child_views(self):

        self.get_radio_option.clicked.connect(self.disp_get_options)
        self.push_radio_option.clicked.connect(self.disp_push_options)
        self.extract_radio_option.clicked.connect(self.disp_ext_options)
        self.compare_radio_option.clicked.connect(self.disp_comp_options)

        self.base_left.go_button.clicked.connect(self.connect_validate_option)

    def connect_validate_option(self):

        self.validations.validate_user_inputs(
        )  # passing self to validation class method , other end this self is last_parent

    def create_views(self):

        self.base_left = left_base(
            self
        )  # we are passing main GUI and also local self as 'last_parent' to left base view to update variables

        self.get_view = get_controls(self.gui, self.base_left)
        self.push_view = push_controls(self.gui, self.base_left)
        self.excel_view = extract_excel(self.gui, self.base_left)
        self.compare_view = compare_op_results(self)

    def show_gif_right_base(self, path, layout):
        print("ui parent view show_gif_right_base line 394")
        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Expanding)
        self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        layout.addWidget(self.movie_screen)

        ag_file = path
        self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
        self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        self.movie.setSpeed(75)
        self.movie_screen.setMovie(self.movie)

        #"C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
        self.movie.setPaused(True)
        self.movie.start()
#         self.right_base_widget.setLayout(layout)
#         self.right_base_widget.show()

    def hide_gif_right_base(self):
        self.movie_screen.hide()
class StatusScrollArea(QScrollArea):
    def __init__(self):
        super(StatusScrollArea, self).__init__()

        self._width = 0
        self._group_count = 0

        self._pan_pos = None

        self.__create_ui()
        self.__init_ui()

    def __create_ui(self):
        self.container = QWidget()
        self.container_layout = QHBoxLayout()

        self.container.setLayout(self.container_layout)
        self.setWidget(self.container)

    def __init_ui(self):
        self.container.setFixedHeight(TOOLBAR_BUTTON_SIZE)
        self.container_layout.setContentsMargins(0, 0, 0, 0)
        self.container_layout.setSpacing(1)
        self.container_layout.setAlignment(Qt.AlignLeft)

        self.setFixedHeight(TOOLBAR_BUTTON_SIZE)
        self.setFocusPolicy(Qt.NoFocus)
        self.setFrameShape(self.NoFrame)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

    def _update_width(self, expand_value):
        self._width += expand_value
        self.container.setFixedWidth(self._width + self._group_count)

    def mousePressEvent(self, event):
        if event.button() == Qt.MidButton:
            QApplication.setOverrideCursor(QCursor(Qt.SizeHorCursor))
            self._pan_pos = event.globalPos()
            event.accept()
        else:
            event.ignore()

    def mouseReleaseEvent(self, event):
        if event.button() == Qt.MidButton:
            QApplication.restoreOverrideCursor()
            self._pan_pos = None
            event.accept()
        else:
            event.ignore()

    def mouseMoveEvent(self, event):
        if self._pan_pos:
            h_bar = self.horizontalScrollBar()
            h_bar_pos = h_bar.sliderPosition()
            cursor_pos = event.globalPos()
            cursor_delta = (cursor_pos - self._pan_pos).x()

            h_bar.setValue(h_bar_pos - cursor_delta)
            self._pan_pos = cursor_pos
            event.accept()
        else:
            event.ignore()

    def wheelEvent(self, event):
        if event.orientation() == Qt.Vertical:
            num_degrees = event.delta() / 8
            h_bar = self.horizontalScrollBar()
            h_bar_pos = h_bar.sliderPosition()

            h_bar.setValue(h_bar_pos - num_degrees)
        else:
            super(StatusScrollArea, self).wheelEvent(event)

    def resizeEvent(self, event):
        max_scroll = max(0, self.container.width() - event.size().width())
        self.horizontalScrollBar().setMaximum(max_scroll)

    def add_widget(self, widget):
        # add widget to layout
        self.container_layout.addWidget(widget)

        # connect widget for future update when user interact with it
        widget.toggled.connect(self._update_width)

        # expand widget layout
        self._width += widget.max_length()
        self._group_count += 1
        self.container.setFixedWidth(self._width)
class StatusCollapsibleLayout(QWidget):
    """ Collapsible layout with Maya Status Line's style """

    toggled = Signal(int)

    def __init__(self, parent=None, section_name=None):
        super(StatusCollapsibleLayout, self).__init__(parent)

        self.icon_buttons = []
        self.state = True

        self.toggle_btn = SeparatorButton()
        if section_name is None:
            section_name = 'Show/Hide section'
        self.toggle_btn.setToolTip(section_name)
        self.toggle_btn.setFlat(True)
        self.toggle_btn.clicked.connect(self.toggle_layout)

        self.group_layout = QHBoxLayout()
        self.group_layout.setAlignment(Qt.AlignLeft)
        self.group_layout.setContentsMargins(0, 0, 0, 0)
        self.group_layout.setSpacing(1)
        self.group_layout.addWidget(self.toggle_btn)

        self.setLayout(self.group_layout)

    def _delta_length(self):
        if self.state:
            return self.max_length() - TOOLBAR_SEPARATOR_WIDTH
        else:
            return TOOLBAR_SEPARATOR_WIDTH - self.max_length()

    def add_button(self, button):
        """ Create a button and add it to the layout

        :param button: QPushButton
        """
        self.icon_buttons.append(button)
        self.group_layout.addWidget(button)

    def toggle_layout(self, init=False):
        """ Toggle collapse action for layout """
        if not init:
            self.state = not self.state

        for btn in self.icon_buttons:
            btn.setVisible(self.state)

        self.toggle_btn.set_collapse(self.state)
        if init:
            self.toggled.emit(0 if self.state else self._delta_length())
        else:
            self.toggled.emit(self._delta_length())

    def set_current_state(self, state):
        self.state = state == 'true' if isinstance(state, unicode) else state
        self.toggle_layout(init=True)

    def button_count(self):
        return len(self.icon_buttons)

    def button_list(self):
        return self.icon_buttons

    def current_state(self):
        return self.state

    def max_length(self):
        count = self.button_count()
        # separator button width + button count * button size + spacing
        return TOOLBAR_SEPARATOR_WIDTH + count * TOOLBAR_BUTTON_SIZE + count