Ejemplo n.º 1
0
 def first_playlist_dj(self):
     send = self.sender()
     id_str = send.objectName()
     self.lock.acquire()
     self.listview_lable.setObjectName("internet")
     if self.src_choose.currentText() == "网易云":
         if id_str[1] == 'p':
             self.date.music_name, self.date.music_id = NCOperation.playlist_info(
                 id_str.split('=')[1])
             self.listview.clear()  # 列表清空
             for i in range(len(self.date.music_name)):  # 加入选中歌单中的歌曲名
                 temp = QListWidgetItem(self.date.music_name[i])
                 temp.setIcon(QIcon("./ico/song.png"))
                 temp.setToolTip("双击播放")
                 self.listview.addItem(temp)
         elif id_str[1] == 'd':
             self.player.setMedia(
                 QMediaContent(
                     QUrl(NCOperation.dj_url(
                         id_str.split('=')[1]))))  # 设置音频网址
             text = self.date.bt_name[self.date.bt_id.index(id_str)]
             self.disc_title.setText(text)  # 显示播放的音频名字
             self.disc.setObjectName("")
             self.listview.setCurrentRow(-1)
             self.player_setting()
     elif self.src_choose.currentText() == "QQ音乐":
         self.message_label.setText("后续跟进")
     self.lock.release()
Ejemplo n.º 2
0
    def populate_episodes(self, selected_podcast_id):
        """ Using the current podcast ID populate the Episodes LIst widget
            with all of the episodes for the selected podcast."""

        # --- start with a clean list of episodes
        self.EpisodesListWidget.clear()

        # --- Get a list of episodes using the podcast id from the api
        self.list_of_episodes = self.podcast_id_2_episodes(selected_podcast_id)

        # --- Check to see if the list of episodes returned from the API is
        #     empty, if so the we are outta here.
        if len(self.list_of_episodes) == 0:
            # TODO: Maybe add a message box to indicate that no episodes
            #       were available for the selected podcast
            return

        for episode in self.list_of_episodes:

            # --- Use the icon from the selected podcast for all episodes
            episode_icon = self.PodcastListWidget.currentItem().icon()

            # --- Create the list item as a native object
            #     To the EpisodesListWidget
            list_item = QListWidgetItem(self.EpisodesListWidget)

            # --- Populate the item test and icon/image
            list_item.setText(
                "Episode ID: %s\n%s\nPublished: %s" %
                (str(episode["id"]), str(episode["attributes"]["title"]),
                 str(episode["attributes"]["published_date"])))
            list_item.setIcon(episode_icon)
Ejemplo n.º 3
0
    def fill_project_list(self):
        self.p_list_widget.clear()
        for project in self.projects_list:
            p_url = project["url"]
            p_id = project["id"]
            p_name = project["name"]
            p_img_hash = project["preview_image_hash"]
            p_img_url = project["preview_image"]

            # Check the hash to see if preview image has changed
            hash_key = p_url
            stored_hash = self.amigo_api.get_hash(hash_key)
            use_cache = False
            if p_img_hash == stored_hash:
                use_cache = True

            p_img = self.amigo_api.fetch_img(p_img_url, use_cache=use_cache)
            self.amigo_api.store_hash(hash_key, p_img_hash)

            # Individual item of the project list. Contains the actual name of the project.
            item = QListWidgetItem(p_name, self.p_list_widget)
            # Now the item has also an icon with the project's preview image
            item.setIcon(self.new_icon(p_img))
            item.setData(Qt.UserRole, p_id)
            # Adds the item to the list
            self.p_list_widget.addItem(item)
            # Resizes the icon so it can be properly visualized
            self.p_list_widget.setIconSize(self.iconSize)

        return self.p_list_widget
Ejemplo n.º 4
0
    def _item_from_action(self, action):

        item = QListWidgetItem(action.id)
        if action.action is not None:
            item.setIcon(action.action.icon())

        return item
Ejemplo n.º 5
0
    def onScreenShot1(self):
        # 截图方式1
        page = self.webView.page()
        frame = page.mainFrame()
        size = frame.contentsSize()
        image = QImage(size, QImage.Format_ARGB32_Premultiplied)
        image.fill(Qt.transparent)

        painter = QPainter()
        painter.begin(image)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setRenderHint(QPainter.TextAntialiasing, True)
        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)

        # 记录旧大小
        oldSize = page.viewportSize()
        # *****重点就是这里******
        page.setViewportSize(size)
        frame.render(painter)
        painter.end()

        # 截图完成后需要还原,否则界面不响应鼠标等
        page.setViewportSize(oldSize)

        # 添加到左侧list中
        item = QListWidgetItem(self.widgetRight)
        image = QPixmap.fromImage(image)
        item.setIcon(QIcon(image))
        item.setData(Qt.UserRole + 1, image)
Ejemplo n.º 6
0
    def get_shop_info(self):    #接收商店信息
        self.ShopList.clear()
        s=socket(AF_INET,SOCK_DGRAM)
        timeout = ip.TIMEOUT
        s.settimeout(timeout)
        info={}
        info["request"]="shopinfo"
        info["timestamp"]=ip.get_time_stamp()
        info = json.dumps(info)
        res=ip.encrypt(info)#encrypt
        s.sendto(res,(ip.HOST,ip.PORT))
        data,ADDR = s.recvfrom(ip.BUFFERSIZE)
        data=ip.decrypt(data)
        shop_dic=eval(data)

        self.shop_id=[]
        shop_num=len(shop_dic)
        for i in range(shop_num):
            string="Shop Name: "+shop_dic[str(i)]["shopname"]+"\n"+"Owner ID: "+shop_dic[str(i)]["id"]+"\n"+"Owner name: "+shop_dic[str(i)]["ownername"]+'\n'
            item=QListWidgetItem()
            item.setIcon(QtGui.QIcon('icon/shop.ico'))
            item.setText(string)
            self.shop_id.append(int(shop_dic[str(i)]["id"]))
            self.ShopList.insertItem(i,item)
        s.close()
Ejemplo n.º 7
0
 def updateView(self, noteNames):
     self.clear()
     for name in noteNames:
         item = QListWidgetItem(name)
         item.setIcon(QIcon('img/markdown-2.png'))
         # item.setFlags(item.flags() | Qt.ItemIsEditable)
         self.addItem(item)
Ejemplo n.º 8
0
 def addPiece(self, pixmap, location):
     pieceItem = QListWidgetItem(self)
     pieceItem.setIcon(QIcon(pixmap))
     pieceItem.setData(Qt.UserRole, pixmap)
     pieceItem.setData(Qt.UserRole + 1, location)
     pieceItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                        | Qt.ItemIsDragEnabled)
Ejemplo n.º 9
0
    def __toolbarComboBox_currentIndexChanged(self, index):
        """
        Private slot called upon a selection of the current toolbar.
        
        @param index index of the new current toolbar (integer)
        """
        itemID = self.toolbarComboBox.itemData(index)
        self.__currentToolBarItem = self.__toolbarItems[itemID]
        self.toolbarActionsList.clear()
        for actionID in self.__currentToolBarItem.actionIDs:
            item = QListWidgetItem(self.toolbarActionsList)
            if actionID is None:
                item.setText(self.__separatorText)
            else:
                action = self.__manager.actionById(actionID)
                item.setText(action.text())
                item.setIcon(action.icon())
                item.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter)
                item.setData(E5ToolBarDialog.ActionIdRole, int(id(action)))
                item.setData(E5ToolBarDialog.WidgetActionRole, False)
                if self.__manager.isWidgetAction(action):
                    item.setData(E5ToolBarDialog.WidgetActionRole, True)
                    item.setData(Qt.TextColorRole, QColor(Qt.blue))
        self.toolbarActionsList.setCurrentRow(0)

        self.__setupButtons()
Ejemplo n.º 10
0
    def set_slice_view(self, slice_image_list):
        if self.show_status is True:
            return
        self.slice_view_list = []
        for i, slice_image in enumerate(slice_image_list):
            slice_qimage = QImage(slice_image.data, slice_image.shape[1],
                                  slice_image.shape[0],
                                  slice_image.shape[1] * slice_image.shape[2],
                                  QImage.Format_RGB888)
            slice_pix = QPixmap.fromImage(slice_qimage)

            if slice_pix.width() > 200 or slice_pix.height() > 200:
                slice_pix = slice_pix.scaled(200, 200, Qt.KeepAspectRatio)

            list_item = QListWidgetItem()
            # list_item.setSizeHint(QSize(200, slice_image.shape[0]))

            # image_layout = QHBoxLayout()
            # image_widget = QWidget()
            # image_widget.setLayout(image_layout)

            # image_label = QLabel()
            # image_label.setFixedWidth(200)
            # image_layout.addWidget(image_label)

            # image_label.setPixmap(slice_pix)

            pix_icon = QIcon(slice_pix)

            list_item.setIcon(pix_icon)
            self.view_list.addItem(list_item)
            # self.view_list.setItemWidget(list_item, image_widget)
            self.slice_view_list.append(list_item)

        self.show_status = True
Ejemplo n.º 11
0
    def changeRemoteDir(self, directory):
        """修改当前的本地目录"""
        # if not path.isdir(directory):
        #     return
        directory = directory or '/'
        self.lstRemote.clear()
        try:
            dirs, files = self.__adb.ls(directory)
            if dirs is None or files is None:
                self.setStatusTip('没有连接设备')
                return
        except ADBException as e:
            self.setStatusTip(e.msg)
            return

        for d in dirs:
            li = QListWidgetItem()
            li.setIcon(MyResources.icons['dir'])
            li.setText(d.name)
            li.fileType = 1
            self.lstRemote.addItem(li)
        for f in files:
            li = QListWidgetItem()
            li.setIcon(MyResources.icons['file'])
            li.setText(f.name)
            li.fileType = 0
            self.lstRemote.addItem(li)
        self.curRemoteDir = directory
Ejemplo n.º 12
0
    def insert_podcast_list_item(self, podcast_id, podcast_image_url,
                                 podcast_title, thread_number):
        """ This is the function that is executed as a thread.
            Take extra care to hanle andy exceptions a python hates
            unhandled exceptions in thread"""
        global THREAD_MONITOR
        THREAD_MONITOR[thread_number] = 1
        try:
            # --- Download the image for this podcast
            podcast_image_file = podcast_player_utils.download_station_logo(
                podcast_image_url)

            # --- Be sure we got an image, if not then use the "image
            #     not available" image
            if len(podcast_image_file) == 0:
                podcast_icon = QIcon(
                    os.path.join(RESOURCE_PATH, "no_image.jpg"))
            else:
                podcast_icon = QIcon(podcast_image_file)

            # --- Create the list item as a native object
            #     To the PodcastListWidget
            list_item = QListWidgetItem(self.PodcastListWidget)

            # --- Populate the item test and icon/image
            list_item.setText("Podcast ID: %s\n%s" %
                              (str(podcast_id), str(podcast_title)))
            list_item.setIcon(podcast_icon)

        except Exception as e:
            pass
        finally:
            THREAD_MONITOR[thread_number] = 0
Ejemplo n.º 13
0
    def createTabWindowStyle(self):
        self.tabWindowStyle = QWidget()
        self.tabWindowStyle.setObjectName("tabWindowStyle")

        self.verticalLayout_6 = QVBoxLayout(self.tabWindowStyle)
        self.verticalLayout_6.setObjectName("verticalLayout_6")

        self.listWidgetWindowStyle = QListWidget(self.tabWindowStyle)
        self.listWidgetWindowStyle.setResizeMode(QListView.Adjust)
        self.listWidgetWindowStyle.setIconSize(QSize(340, 105))
        self.listWidgetWindowStyle.setViewMode(QListView.IconMode)
        self.listWidgetWindowStyle.setObjectName("listWidgetWindowStyle")

        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/data/images/breeze-window.png"))
        item.setIcon(icon)
        item.setText("Breeze")
        item.setStyleText = "org.kde.breeze"
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon1 = QIcon()
        icon1.addPixmap(QPixmap(":/data/images/oxygen-window.png"))
        item.setIcon(icon1)
        item.setText("Oxygen")
        item.setStyleText = "org.kde.oxygen"

        self.verticalLayout_6.addWidget(self.listWidgetWindowStyle)

        self.addTab(self.tabWindowStyle, self.tr("Window Style"))
Ejemplo n.º 14
0
    def loadFood(self):
        """
        Load all the user's food from instagram - depending on Yum4FIT hashtag
        """
        self.foods = account.getAllFood(self.profile.username, self.password,
                                        self.hashtag)
        listView = self.w.findChild(QtWidgets.QListWidget, 'listFoods')
        listView.setViewMode(QListView.IconMode)
        listView.setIconSize(QSize(400, 400))
        listView.clear()

        for actual in self.foods:
            f = actual.split(' ')

            url = f[1]
            data = urllib.request.urlopen(url).read()
            image = QtGui.QImage()
            image.loadFromData(data)
            map = QtGui.QPixmap(image)

            item = QListWidgetItem(f[0])
            icon = QtGui.QIcon()
            icon.addPixmap(map, QtGui.QIcon.Normal, QtGui.QIcon.Off)
            item.setIcon(icon)
            listView.addItem(item)
    def search_goods(self): #获取当前商店的商品信息
        self.listWidget.clear()
        s=socket(AF_INET,SOCK_DGRAM)
        timeout = ip.TIMEOUT
        s.settimeout(timeout)
        info={}
        info["request"]="getgoods"
        info["shop_id"]=str(self.shop_id)
        info["timestamp"]=ip.get_time_stamp()
        info = json.dumps(info)
        res=ip.encrypt(info)#encrypt
        s.sendto(res,(ip.HOST,ip.PORT))
        data,ADDR = s.recvfrom(ip.BUFFERSIZE)
        data=ip.decrypt(data)

        goods_dic=eval(data)
        self.goods_id={}
        self.goods_name={}
        self.goods_price={}
        goods_num=len(goods_dic)
        for i in range(goods_num):
            if str(goods_dic[str(i)]["num"])!='0':
                string="Good Name: "+goods_dic[str(i)]["good_name"]+"\n"+"Good ID: "+goods_dic[str(i)]["good_id"]+"\n"+"Good Price: "+goods_dic[str(i)]["price"]+"\n"+"Num Left: "+str(goods_dic[str(i)]["num"])
                item=QListWidgetItem()
                item.setIcon(QtGui.QIcon('icon/list.ico'))
                item.setText(string)
                self.goods_id[i]=(int(goods_dic[str(i)]["good_id"]))
                self.goods_name[i]=goods_dic[str(i)]["good_name"]
                ss=goods_dic[str(i)]["price"]
                ss=ss.replace("$","")
                self.goods_price[i]=float(ss)
                self.listWidget.insertItem(i,item)
        s.close()
Ejemplo n.º 16
0
 def on_scrapped_channels(self, channels):
     self.channels = channels
     for channel in self.channels:
         item = QListWidgetItem()
         item.setText(channel['name'])
         item.setIcon(QIcon(channel['logo']))
         self.lw_channels.addItem(item)
Ejemplo n.º 17
0
    def createTabWindowStyle(self):
        self.tabWindowStyle = QWidget()
        self.tabWindowStyle.setObjectName("tabWindowStyle")

        self.verticalLayout_6 = QVBoxLayout(self.tabWindowStyle)
        self.verticalLayout_6.setObjectName("verticalLayout_6")

        self.listWidgetWindowStyle = QListWidget(self.tabWindowStyle)
        self.listWidgetWindowStyle.setResizeMode(QListView.Adjust)
        self.listWidgetWindowStyle.setIconSize(QSize(340, 105))
        self.listWidgetWindowStyle.setViewMode(QListView.IconMode)
        self.listWidgetWindowStyle.setObjectName("listWidgetWindowStyle")

        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap("/usr/share/kaptan/images/breeze-window.png"))
        item.setIcon(icon)
        item.setText("Breeze")
        item.setStyleText = "org.kde.breeze"
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon1 = QIcon()
        icon1.addPixmap(QPixmap("/usr/share/kaptan/images/oxygen-window.png"))
        item.setIcon(icon1)
        item.setText("Oxygen")
        item.setStyleText = "org.kde.oxygen"

        self.verticalLayout_6.addWidget(self.listWidgetWindowStyle)

        self.addTab(self.tabWindowStyle, self.tr("Window Style"))
Ejemplo n.º 18
0
 def __toolbarComboBox_currentIndexChanged(self, index):
     """
     Private slot called upon a selection of the current toolbar.
     
     @param index index of the new current toolbar (integer)
     """
     itemID = self.toolbarComboBox.itemData(index)
     self.__currentToolBarItem = self.__toolbarItems[itemID]
     self.toolbarActionsList.clear()
     for actionID in self.__currentToolBarItem.actionIDs:
         item = QListWidgetItem(self.toolbarActionsList)
         if actionID is None:
             item.setText(self.__separatorText)
         else:
             action = self.__manager.actionById(actionID)
             item.setText(action.text())
             item.setIcon(action.icon())
             item.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter)
             item.setData(E5ToolBarDialog.ActionIdRole, int(id(action)))
             item.setData(E5ToolBarDialog.WidgetActionRole, False)
             if self.__manager.isWidgetAction(action):
                 item.setData(E5ToolBarDialog.WidgetActionRole, True)
                 item.setData(Qt.TextColorRole, QColor(Qt.blue))
     self.toolbarActionsList.setCurrentRow(0)
     
     self.__setupButtons()
Ejemplo n.º 19
0
 def initCategories(self):
     generalButton = QListWidgetItem(self.categories)
     generalButton.setIcon(QIcon(':/images/settings-general.png'))
     generalButton.setText('General')
     generalButton.setToolTip('General settings')
     generalButton.setTextAlignment(Qt.AlignHCenter)
     generalButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     videoButton = QListWidgetItem(self.categories)
     videoButton.setIcon(QIcon(':/images/settings-video.png'))
     videoButton.setText('Video')
     videoButton.setToolTip('Video settings')
     videoButton.setTextAlignment(Qt.AlignHCenter)
     videoButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     themeButton = QListWidgetItem(self.categories)
     themeButton.setIcon(QIcon(':/images/settings-theme.png'))
     themeButton.setText('Theme')
     themeButton.setToolTip('Theme settings')
     themeButton.setTextAlignment(Qt.AlignHCenter)
     themeButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     ffmpegButton = QListWidgetItem(self.categories)
     ffmpegButton.setIcon(QIcon(':/images/settings-ffmpeg.png'))
     ffmpegButton.setText('Tools')
     ffmpegButton.setToolTip('Tools settings')
     ffmpegButton.setTextAlignment(Qt.AlignHCenter)
     ffmpegButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     logsButton = QListWidgetItem(self.categories)
     logsButton.setIcon(QIcon(':/images/settings-logs.png'))
     logsButton.setText('Logs')
     logsButton.setToolTip('Logging settings')
     logsButton.setTextAlignment(Qt.AlignHCenter)
     logsButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     self.categories.currentItemChanged.connect(self.changePage)
     self.categories.setCurrentRow(0)
     self.categories.setMaximumWidth(
         self.categories.sizeHintForColumn(0) + 2)
Ejemplo n.º 20
0
    def inspection_files(self, dir_name,
                         sql_dir_name):  # Проверяем файлы и даем иконки
        self.path = self.inspection_path(dir_name.replace('"', "'"),
                                         sql_dir_name)
        if self.path:
            self.lw_file.clear()
            files = listdir("%s/%s" %
                            (self.path_wor, dir_name.replace('"', "'")))
            for file in files:
                if "~" not in file:
                    r = path.splitext(file)  # Получаем название и расширение
                    if "xlsx" in r[1][1:] or "xlsm" in r[1] or "xls" in r[
                            1] or "xlt" in r[1]:
                        ico = "xlsx"
                    elif "xml" in r[1][1:] or "docx" in r[1] or "doc" in r[
                            1] or "docm" in r[1]:
                        ico = "xml"
                    elif "png" in r[1] or "jpg" in r[1] or "jpeg" in r[
                            1] or "jpe" in r[1] or "gif" in r[1] or "bmp" in r[
                                1]:
                        ico = "image"
                    elif "pdf" in r[1]:
                        ico = "pdf"
                    else:
                        ico = "other"

                    list_item = QListWidgetItem(r[0] + r[1])
                    list_item.setIcon(QIcon(getcwd() + "/images/%s.ico" % ico))
                    self.lw_file.addItem(list_item)
    def new_elements(self):
        self.list_of_btns.clear()
        self.conn = sql.connect('clockworkdb.db')
        self.c = self.conn.cursor()
        cw_mass = self.c.execute("""SELECT * FROM clockworkbase""").fetchall()
        days = ''
        for i in cw_mass:
            id = i[0]
            if int(i[2].split(':')[0]) < 10:
                cw_time_hour = '0' + i[2].split(':')[0]
            else:
                cw_time_hour = i[2].split(':')[0]
            if int(i[2].split(':')[1]) < 10:
                cw_time_minute = '0' + i[2].split(':')[1]
            else:
                cw_time_minute = i[2].split(':')[1]
            for symbl in ''.join(sorted([smbl for smbl in str(i[1])])):
                week_dict = {1: "Mon", 2: "Tue", 3: "Wed", 4: "Thu", 5: "Fri",
                             6: "Sat", 7: "Sun"}
                days += (week_dict[int(symbl)] + '; ')

            itm = QListWidgetItem(f"{id} | {cw_time_hour}:{cw_time_minute} | {days}")
            if not i[-1]:
                itm.setIcon(QIcon(r"pusto.png"))
            else:
                itm.setIcon(QIcon(i[-1]))
            self.list_of_btns.setIconSize(QSize(30, 30))
            self.list_of_btns.addItem(itm)  # .setIcon('alliteamsicon.jpg')
            days = ''
        self.parent.check_clockwork()
Ejemplo n.º 22
0
def look_for_cars():
    grid_cars.setViewMode(QListView.IconMode)
    grid_cars.setIconSize(QtCore.QSize(128, 128))

    cars = []

    for file in os.listdir(configs['rvgl_custom_path'] + '/cars/'):
        if os.path.isdir(configs['rvgl_custom_path'] + '/cars/' + file):
            car_path = os.path.join(configs['rvgl_custom_path'] + '/gfx/',
                                    file)
            cars.append(Car(file, car_path))

    for car in cars:
        car_img = os.path.join(configs['rvgl_custom_path'], 'cars',
                               car.car_name, 'carbox.bmp')
        if not os.path.isfile(car_img):
            car_img = os.path.join(configs['rvgl_custom_path'], 'gfx',
                                   'bot_bat.bmp')

        item = QListWidgetItem()
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(car_img), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        item.setIcon(icon)
        item.setText(car.car_name)
        grid_cars.addItem(item)
Ejemplo n.º 23
0
def add_item(obj,
             icon: str = "",
             text: str = "",
             tooltip: str = "",
             selectable: bool = False,
             select: bool = False,
             checkable: bool = False,
             check: bool = False,
             hide: bool = False,
             font_size: int = 12,
             icon_size=(25, 25)):

    font = QFont()
    font.setPointSize(font_size)

    att = QListWidgetItem()
    att.setText(text)
    att.setHidden(hide)
    att.setFont(font)

    if icon:
        att.setIcon(icon)
    if tooltip:
        att.setToolTip(tooltip)
    if checkable:
        att.setCheckState(check)
    if selectable:
        att.setSelected(select)

    obj.setIconSize(QSize(icon_size[0], icon_size[1]))

    return att
Ejemplo n.º 24
0
    def open_src_img(self):
        fileNames_choose, filetype = QFileDialog.getOpenFileNames(
            self,
            "选取图片文件",
            self.cwd,  # 起始路径
            "(*.jpg);;(*.png)")  # 设置文件扩展名过滤,用双分号间隔
        if len(fileNames_choose) == 0:
            print("\n取消选择")
            return

        self.src_img_path = fileNames_choose[0]

        if self.load_scaled_src_img() == -1:
            return

        self.ui.list_src_show.clear()
        item = QListWidgetItem()
        item.setIcon(QIcon(self.src_img_path))
        item.setSizeHint(QSize(256, 256))
        self.ui.list_src_show.setIconSize(QSize(256, 256))
        self.ui.list_src_show.addItem(item)

        #加载其他选中的文件
        for path in fileNames_choose:
            self.src_img_paths.append(path)

        self.load_all_src_img()
Ejemplo n.º 25
0
    def setupWidgets(self):
        """
        Create and arrange widgets in window
        """
        icon_label = QLabel("ICONS", self)
        icon_widget = QListWidget()
        icon_widget.setAcceptDrops(True)
        icon_widget.setDragEnabled(True)
        icon_widget.setViewMode(QListWidget.IconMode)

        image_path = "images"
        for img in os.listdir(image_path):
            list_item = QListWidgetItem()
            list_item.setText(img.split(".")[0])
            list_item.setIcon(
                QIcon(os.path.join(image_path, "{0}").format(img)))
            icon_widget.setIconSize(QSize(50, 50))
            icon_widget.addItem(list_item)

        list_label = QLabel("LIST", self)
        list_widget = QListWidget()
        list_widget.setAlternatingRowColors(True)
        list_widget.setAcceptDrops(True)
        list_widget.setDragEnabled(True)

        # create grid layout
        grid = QGridLayout()
        grid.addWidget(icon_label, 0, 0)
        grid.addWidget(list_label, 0, 1)
        grid.addWidget(icon_widget, 1, 0)
        grid.addWidget(list_widget, 1, 1)

        self.setLayout(grid)
Ejemplo n.º 26
0
    def fill_datasets_list(self, project_id):
        self.ds_list_widget.clear()
        dataset_list = self.amigo_api.fetch_dataset_list(project_id)
        for dataset in dataset_list:
            if dataset["visible"]:
                ds_url = dataset["url"]
                ds_id = dataset["id"]
                ds_name = dataset["name"]
                ds_schema_hash = dataset["schema_hash"]
                ds_img_hash = dataset["preview_image_hash"]
                ds_img_url = dataset["preview_image"]

                # Check the hash to see if preview image has changed
                hash_key = ds_url
                stored_hash = self.amigo_api.get_hash(hash_key)
                use_cache = False
                if ds_img_hash == stored_hash:
                    use_cache = True

                ds_img = self.amigo_api.fetch_img(ds_img_url,
                                                  use_cache=use_cache)
                self.amigo_api.store_hash(hash_key, ds_img_hash)

                item = QListWidgetItem(ds_name, self.ds_list_widget)
                item.setIcon(self.new_icon(ds_img))
                item.setData(Qt.UserRole, ds_id)
                self.ds_list_widget.addItem(item)
                self.ds_list_widget.setIconSize(self.iconSize)
Ejemplo n.º 27
0
    def addFolder(self):
        dial = QFileDialog()

        try:
            if self.firstOpen:
                name = dial.getExistingDirectory(self, "Choose folder",
                                                 QDir.homePath())
                self.firstOpen = False
            else:
                name = dial.getExistingDirectory(self, "Choose folder")
            fold = os.path.basename(name)
            folpath = os.getcwd()
            shutil.copytree(name, os.path.join('tmp', fold))
            folpath = os.path.join(folpath, 'tmp', fold)
        except Exception:
            dial.accept()
            return

        a = QListWidgetItem(fold)
        a.setIcon(QIcon(os.path.join('Resources', 'folder.png')))
        a.setSizeHint(
            QSize(100 / 1920 * self.screenWidth,
                  33 / 1080 * self.screenHeight))
        a.__dict__['folderpath'] = folpath
        self.list.addItem(a)
Ejemplo n.º 28
0
    def initUI(self):
        self.setViewMode(QListView.IconMode)
        for item in self.menus:
            widgetItem = QListWidgetItem(self)
            widgetItem.metadata = item
            widgetItem.setText(item['title'])
            widgetItem.setToolTip(item.get('description', ''))
            widgetItem.setIcon(QIcon(item['icon']))
            self.addItem(widgetItem)

        self.setCurrentRow(0)
        self.setIconSize(QSize(32, 32))
        self.setMovement(QListView.Static)
        self.setUniformItemSizes(True)

        # self.setSize()
        self.setStyleSheet("""QListWidget::Item {
	padding-left: 10px;
	padding-right: 10px;
	padding-bottom: 5px;
}""")

        shadow = QGraphicsDropShadowEffect(self)
        shadow.setColor(Qt.black)
        shadow.setBlurRadius(10)
        shadow.setOffset(0, 0)
        self.setGraphicsEffect(shadow)
Ejemplo n.º 29
0
    def __insert_volumes(self, volumes):
        # self.volume_icons = []
        # volumes = get_storage().fetch_volumes()

        # abdig_sort = lambda var: [int(x) if x.isdigit() else x for x in re.findall(r'[^0-9]|[0-9]+', var.name)]

        # volumes.sort(key=lambda vnode: vnode.name)
        # volumes.sort(key=abdig_sort)
        convert = lambda text: int(text) if text.isdigit() else text
        alphanum_key = lambda key: [
            convert(c) for c in re.split(r'([0-9]+)', key.name)
        ]
        volumes.sort(key=alphanum_key)

        #
        # names = [x.name for x in volumes]
        # print(natsorted(names))

        for vnode in volumes:

            list_item = QListWidgetItem(vnode.name)
            icon = get_volume_icon(vnode.vtype)
            list_item.setData(Qt.UserRole + 1, vnode.uuid)
            list_item.setIcon(icon)

            # ivolume = volume_icon(vnode.vtype)
            # ivolume = ticons.vicon(vnode.vtype)
            # self.volume_icons.append(ivolume)
            # self.__list.insert('', 'end', vnode.uuid, text=vnode.name, tags=("simple", ), image=ivolume)
            # self.__volumes_map[vnode.uuid] = vnode

            self.ilist.addItem(list_item)
    def on_patchSelector_activated(self, patch):
        """
        Private slot to get the list of guards for the given patch name.
        
        @param patch selected patch name (empty for current patch)
        """
        self.guardsList.clear()
        self.patchNameLabel.setText("")

        args = self.vcs.initCommand("qguard")
        if patch:
            args.append(patch)

        output = self.__hgClient.runcommand(args)[0].strip()

        if output:
            patchName, guards = output.split(":", 1)
            self.patchNameLabel.setText(patchName)
            guardsList = guards.strip().split()
            for guard in guardsList:
                if guard.startswith("+"):
                    icon = UI.PixmapCache.getIcon("plus.png")
                    guard = guard[1:]
                elif guard.startswith("-"):
                    icon = UI.PixmapCache.getIcon("minus.png")
                    guard = guard[1:]
                else:
                    icon = None
                    guard = self.tr("Unguarded")
                itm = QListWidgetItem(guard, self.guardsList)
                if icon:
                    itm.setIcon(icon)
Ejemplo n.º 31
0
 def renderTimes(self) -> None:
     self.cliplist.clear()
     self.seekSlider.setCutMode(self.inCut)
     if len(self.clipTimes) > 4:
         self.cliplist.setFixedWidth(200)
     else:
         self.cliplist.setFixedWidth(185)
     self.totalRuntime = 0
     for item in self.clipTimes:
         endItem = ''
         if type(item[1]) is QTime:
             endItem = item[1].toString(self.timeformat)
             self.totalRuntime += item[0].msecsTo(item[1])
         listitem = QListWidgetItem()
         listitem.setTextAlignment(Qt.AlignVCenter)
         if type(item[2]) is QPixmap:
             listitem.setIcon(QIcon(item[2]))
         self.cliplist.addItem(listitem)
         marker = QLabel(
             '''<style>b { font-size:8pt; } p { margin:5px; }</style>
                         <p><b>START</b><br/>%s</p><p><b>END</b><br/>%s</p>'''
             % (item[0].toString(self.timeformat), endItem))
         self.cliplist.setItemWidget(listitem, marker)
         listitem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDragEnabled
                           | Qt.ItemIsEnabled)
     if len(self.clipTimes) and not self.inCut:
         self.saveAction.setEnabled(True)
     if self.inCut or len(self.clipTimes) == 0 or not type(
             self.clipTimes[0][1]) is QTime:
         self.saveAction.setEnabled(False)
     self.setRunningTime(
         self.deltaToQTime(self.totalRuntime).toString(self.timeformat))
Ejemplo n.º 32
0
    def displayPicture(self, item):
        pic_id, index = item.data(0)
        picture = self.PL.getPictureWithID(pic_id)
        self.cur_displayed_picture = QPixmap(picture.file_path)
        self.cur_displayed_picture_index = index
        self.cur_displayed_picture_id = pic_id
        picture_scaled = self.cur_displayed_picture.scaled(
            self.view_photo_widget.picture_lb.sizeHint(), Qt.KeepAspectRatio)
        self.view_photo_widget.picture_lb.setPixmap(picture_scaled)

        self.view_photo_widget.face_list.clear()
        faces = self.PL.getFacesInPicture(pic_id)
        if faces is None:
            return
        for face in faces:
            face_item = QListWidgetItem(self.view_photo_widget.face_list)
            icon = QIcon(face.sample_path)
            face_item.setIcon(icon)
            if face.person_id is None:
                face_item.setText('Unknown')
            else:
                person = self.PL.getPersonById(face.person_id)
                face_item.setText(person.name)
            face_item.setData(Qt.UserRole, face)
            face_item.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled
                               | Qt.ItemIsSelectable)
            self.view_photo_widget.face_list.addItem(face_item)
        self.view_photo_widget.show()
Ejemplo n.º 33
0
    def add_exist(self, name, dir):
        self.exist_projects.append((name, dir))

        item = QListWidgetItem()
        item.setText(name)
        item.setData(self._PROJECT_DIR_ROLE, dir)
        item.setIcon(QIcon.fromTheme("package_games"))

        self.projects_list.addItem(item)
Ejemplo n.º 34
0
 def wallpaperSelectDialog(self):
     file_url, file_type = QFileDialog.getOpenFileName(self, self.tr("Choose wallpaper"), QDir.homePath(), "Image (*.png *.jpg)")
     print(file_url)
     if not "" == file_url:
         self.selectWallpaper = file_url
         item = QListWidgetItem(self.listWidget)
         item.setIcon(QIcon(file_url))
         item.screenshotPath = file_url
         item.userSelect = True
         self.listWidget.setCurrentItem(item)
Ejemplo n.º 35
0
 def populate(self):
     total = 0
     self.ui.player_list.clear()
     for player in self.players.keys():
         list_item = QListWidgetItem(player)
         race = self.players[player].get_race()
         gender = self.players[player].get_gender()
         list_item.setIcon(QtGui.QIcon(preview_icon(race, gender)))
         self.ui.player_list.addItem(list_item)
         total += 1
     self.ui.total_label.setText(str(total) + " total")
     self.ui.player_list.setCurrentRow(0)
Ejemplo n.º 36
0
 def push_button_action(self, main_window_instance):
     line_text = main_window_instance.line_edit.text()
     current_tab = main_window_instance.tab_widget.currentWidget()
     current_widget = current_tab.children()[0]
     item = QListWidgetItem(current_widget)
     check_for_icon = Client.check_text(line_text)
     if check_for_icon is True:
         path = os.path.dirname(os.path.abspath(__file__))
         item.setIcon(QIcon(path + "/codebase/client/pictures/python.jpg"))
     item.setText("%s: %s" % (self.username, line_text))
     self.client.send(line_text, current_tab)
     main_window_instance.line_edit.clear()
Ejemplo n.º 37
0
    def createTabIconSet(self):
        self.tabIconSet = QWidget()
        self.tabIconSet.setObjectName("tabIconSet")

        self.verticalLayout_3 = QVBoxLayout(self.tabIconSet)
        self.verticalLayout_3.setObjectName("verticalLayout_3")

        self.listWidgetIconSet = QListWidget(self.tabIconSet)
        self.listWidgetIconSet.setResizeMode(QListView.Adjust)
        self.listWidgetIconSet.setObjectName("listWidgetIconSet")
        self.listWidgetIconSet.setViewMode(QListView.IconMode)
        self.listWidgetIconSet.setIconSize(QSize(370, 64))
        
        item = QListWidgetItem(self.listWidgetIconSet)
        item.setIcon(QIcon(":/data/images/midna-set.png"))
        item.setText("Midna")
        
        item = QListWidgetItem(self.listWidgetIconSet)
        item.setIcon(QIcon(":/data/images/midna-dark-set.png"))
        item.setText("MidnaDark")
        
        item = QListWidgetItem(self.listWidgetIconSet)
        item.setIcon(QIcon(":/data/images/breeze-set.png"))
        item.setText("Breeze")

        item = QListWidgetItem(self.listWidgetIconSet)
        item.setIcon(QIcon(":/data/images/oxygen-set.png"))
        item.setText("Oxygen")

        self.verticalLayout_3.addWidget(self.listWidgetIconSet)

        self.addTab(self.tabIconSet, self.tr("Icon Set"))
Ejemplo n.º 38
0
    def wallpapersParser(self):
        wallpaperPath = "/usr/share/wallpapers"
        for folder in os.listdir(wallpaperPath):
            path = join(wallpaperPath,folder, "contents")
            thumbFolder = os.listdir(path)
            for thumb in thumbFolder:
                if thumb.startswith("scre"):
                    item = QListWidgetItem(self.listWidget)

                    pix = QPixmap(join(path, thumb))
                    pix = pix.scaled(QSize(240, 140), Qt.IgnoreAspectRatio, Qt.FastTransformation)

                    item.setIcon(QIcon(pix))
                    item.setSizeHint(QSize(250, 150))
                    item.screenshotPath = join(path, thumb)
Ejemplo n.º 39
0
    def emit(self, record):
        try:
            item = QListWidgetItem(self.format(record))
            if record.levelno > logging.INFO:
                item.setIcon(QIcon.fromTheme("dialog-warning"))
                item.setForeground(QBrush(Qt.red))

            else:
                item.setIcon(QIcon.fromTheme("dialog-information"))

            self.app.exec_in_main(self._add_item, item)

        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record)
Ejemplo n.º 40
0
 def on_patchSelector_activated(self, patch):
     """
     Private slot to get the list of guards for the given patch name.
     
     @param patch selected patch name (empty for current patch)
     """
     self.guardsList.clear()
     self.patchNameLabel.setText("")
     
     args = self.vcs.initCommand("qguard")
     if patch:
         args.append(patch)
     
     output = ""
     if self.__hgClient:
         output = self.__hgClient.runcommand(args)[0].strip()
     else:
         process = QProcess()
         process.setWorkingDirectory(self.__repodir)
         process.start('hg', args)
         procStarted = process.waitForStarted(5000)
         if procStarted:
             finished = process.waitForFinished(30000)
             if finished and process.exitCode() == 0:
                 output = str(process.readAllStandardOutput(),
                              self.vcs.getEncoding(), 'replace').strip()
     
     if output:
         patchName, guards = output.split(":", 1)
         self.patchNameLabel.setText(patchName)
         guardsList = guards.strip().split()
         for guard in guardsList:
             if guard.startswith("+"):
                 icon = UI.PixmapCache.getIcon("plus.png")
                 guard = guard[1:]
             elif guard.startswith("-"):
                 icon = UI.PixmapCache.getIcon("minus.png")
                 guard = guard[1:]
             else:
                 icon = None
                 guard = self.tr("Unguarded")
             itm = QListWidgetItem(guard, self.guardsList)
             if icon:
                 itm.setIcon(icon)
Ejemplo n.º 41
0
    def populatesThemesList(self):
        paths = allPaths("resources/themes")
        current = settings.fullScreenTheme
        self.lstThemes.clear()

        for p in paths:
            lst = [i for i in os.listdir(p) if os.path.splitext(i)[1] == ".theme"]
            for t in lst:
                theme = os.path.join(p, t)
                editable = not appPath() in theme
                n = getThemeName(theme)

                item = QListWidgetItem(n)
                item.setData(Qt.UserRole, theme)
                item.setData(Qt.UserRole + 1, editable)
                item.setToolTip("{}{}".format(
                    n,
                    self.tr(" (read-only)") if not editable else ""))

                thumb = os.path.join(p, t.replace(".theme", ".jpg"))
                px = QPixmap(200, 120)
                px.fill(Qt.white)
                if not os.path.exists(thumb):
                    currentScreen = qApp.desktop().screenNumber(self)
                    screenRect = qApp.desktop().screenGeometry(currentScreen)
                    thumb = createThemePreview(theme, screenRect)

                icon = QPixmap(thumb).scaled(200, 120, Qt.KeepAspectRatio)
                painter = QPainter(px)
                painter.drawPixmap(px.rect().center() - icon.rect().center(), icon)
                painter.end()
                item.setIcon(QIcon(px))

                self.lstThemes.addItem(item)

                if current and current in t:
                    self.lstThemes.setCurrentItem(item)
                    current = None

        self.lstThemes.setIconSize(QSize(200, 120))

        if current:  # the theme from settings wasn't found
            # select the last from the list
            self.lstThemes.setCurrentRow(self.lstThemes.count() - 1)
Ejemplo n.º 42
0
    def _add_torrent_item(self, state: TorrentState):
        widget = TorrentListWidgetItem()
        widget.state = state

        item = QListWidgetItem()
        item.setIcon(file_icon if state.single_file_mode else directory_icon)
        item.setSizeHint(widget.sizeHint())
        item.setData(Qt.UserRole, state.info_hash)

        items_upper = 0
        for i in range(self._list_widget.count()):
            prev_item = self._list_widget.item(i)
            if self._list_widget.itemWidget(prev_item).state.suggested_name > state.suggested_name:
                break
            items_upper += 1
        self._list_widget.insertItem(items_upper, item)

        self._list_widget.setItemWidget(item, widget)
        self._torrent_to_item[state.info_hash] = item
Ejemplo n.º 43
0
    def update_playlist(self):
        self.lst_presets.clear()
        presets = self.app.playlist.get()
        current = self.app.playlist.get_active_preset()
        next = self.app.playlist.get_next_preset()
        cur_item = None
        for preset in presets:
            item = QListWidgetItem(preset.name())

            #TODO: Enable renaming in the list when we have a real delegate
            #item.setFlags(item.flags() | Qt.ItemIsEditable)
            if not preset.parameter('allow-playback').get():
                item.setIcon(self.icon_disabled)
            else:
                if preset == current:
                    cur_item = item
                    item.setIcon(self.icon_playing)
                elif preset == next:
                    item.setIcon(self.icon_next)
                else:
                    item.setIcon(self.icon_blank)

            self.lst_presets.addItem(item)

        if cur_item and not self.just_clicked:
            self.lst_presets.scrollToItem(cur_item, QAbstractItemView.PositionAtTop)
        elif self.just_clicked:
            self.just_clicked = False

        if self.transition_in_progress and self.mixer.transition_progress >= 1.0:
            self.slider_transition.setStyleSheet("QSlider { background-color: rgba(0, 0, 0, 0) }")

            if self.transition_right_to_left:
                self.slider_transition.setValue(0)
            else:
                self.slider_transition.setValue(100)

            self.transition_right_to_left = not self.transition_right_to_left
            self.transition_in_progress = False
            self.transition_update_timer.stop()

        if current and next:
            if self.transition_right_to_left:
                self.lbl_transition_left.setText(next.name())
                self.lbl_transition_right.setText(current.name())
            else:
                self.lbl_transition_left.setText(current.name())
                self.lbl_transition_right.setText(next.name())
        else:
            self.lbl_transition_left.setText("")
            self.lbl_transition_right.setText("")
Ejemplo n.º 44
0
    def user_playlist(self):
        self.listWidget.clear()
        r = server.getServer('user/playlists', {'token':session_lib.get_token()})
        playlists = r['payload']['playlists']
        self.listWidget.itemClicked.connect(self.playlist_changed)
        my_item2 = QListWidgetItem()
        my_item2.setText('Browse Music')
        my_item2.setIcon(QIcon("images/browse-music.png"))
        my_item2.setData(Qt.UserRole, 0)
        self.listWidget.addItem(my_item2)
        #http://stackoverflow.com/questions/13536839/qt-how-to-improve-my-contextmenu
        self.listWidget.setContextMenuPolicy(Qt.CustomContextMenu)
        self.listWidget.customContextMenuRequested.connect(self.handleContext)
        for p in playlists:
            my_item=QListWidgetItem()
            my_item.setText(p['name'])
            self.listWidget.addItem(my_item)

            myObject=str(p['id'])
            my_item.setIcon(QIcon("images/playlist-icon.png"))   
            my_item.setData(Qt.UserRole, myObject)
Ejemplo n.º 45
0
    def inspection_files(self, dir_name, sql_dir_name):   # Проверяем файлы и даем иконки
        self.path = self.inspection_path(dir_name.replace('"', "'"), sql_dir_name)
        if self.path:
            self.lw_file.clear()
            files = listdir("%s/%s" % (self.path_wor, dir_name.replace('"', "'")))
            for file in files:
                if "~" not in file:
                    r = path.splitext(file)  # Получаем название и расширение
                    if "xlsx" in r[1][1:] or "xlsm" in r[1] or "xls" in r[1] or "xlt" in r[1]:
                        ico = "xlsx"
                    elif "xml" in r[1][1:] or "docx" in r[1] or "doc" in r[1] or "docm" in r[1]:
                        ico = "xml"
                    elif "png" in r[1] or "jpg" in r[1] or "jpeg" in r[1] or "jpe" in r[1] or "gif" in r[1] or "bmp" in r[1]:
                        ico = "image"
                    elif "pdf" in r[1]:
                        ico = "pdf"
                    else:
                        ico = "other"

                    list_item = QListWidgetItem(r[0] + r[1])
                    list_item.setIcon(QIcon(getcwd() + "/images/%s.ico" % ico))
                    self.lw_file.addItem(list_item)
Ejemplo n.º 46
0
    def _makeItem(self, layer):
        isDefault = layer is self._layerSet.defaultLayer
        name = layer.name
        color = layer.color
        item = QListWidgetItem()
        item.setText(name)
        if color:
            pixmap = QPixmap(100, 100)
            # change color
            pixmap.fill(QColor.fromRgbF(*color))
            icon = QIcon(pixmap)
        else:
            icon = QIcon(":/resources/defaultColor.svg")
        item.setIcon(icon)

        if isDefault:
            font = item.font()
            font.setBold(True)
            item.setFont(font)

        item.setFlags(item.flags() | Qt.ItemIsEditable)

        return item;
Ejemplo n.º 47
0
 def on_rightButton_clicked(self):
     """
     Private slot to add an action to the list.
     """
     row = self.toolbarActionsList.currentRow() + 1
         
     item = QListWidgetItem()
     if self.actionsTree.currentItem().text(0) == self.__separatorText:
         item.setText(self.__separatorText)
         actionID = None
     else:
         actionID = self.actionsTree.currentItem()\
             .data(0, E5ToolBarDialog.ActionIdRole)
         action = self.__manager.actionById(actionID)
         item.setText(action.text())
         item.setIcon(action.icon())
         item.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter)
         item.setData(E5ToolBarDialog.ActionIdRole, int(id(action)))
         item.setData(E5ToolBarDialog.WidgetActionRole, False)
         if self.__manager.isWidgetAction(action):
             item.setData(E5ToolBarDialog.WidgetActionRole, True)
             item.setData(Qt.TextColorRole, QColor(Qt.blue))
             oldTbItemID = self.__widgetActionToToolBarItemID[actionID]
             if oldTbItemID is not None:
                 self.__toolbarItems[oldTbItemID].actionIDs.remove(actionID)
                 self.__toolbarItems[oldTbItemID].isChanged = True
                 self.__toolBarItemToWidgetActionID[oldTbItemID]\
                     .remove(actionID)
             self.__widgetActionToToolBarItemID[actionID] = \
                 id(self.__currentToolBarItem)
             self.__toolBarItemToWidgetActionID[
                 id(self.__currentToolBarItem)].append(actionID)
     self.toolbarActionsList.insertItem(row, item)
     self.__currentToolBarItem.actionIDs.insert(row, actionID)
     self.__currentToolBarItem.isChanged = True
     self.toolbarActionsList.setCurrentRow(row)
     self.__setupButtons()
Ejemplo n.º 48
0
 def run(self):
     """
     Run method that makes an infinite loop
     and receives continuous data from the server socket
     """
     while True:
         try:
             data = self.receive()
             print(data)
             data = self.receive_message(data)
             print("Got data: ", data)
             if data is True:
                 continue
             tab = self.set_data_to_correct_tab(data['type'])
             item = QListWidgetItem(tab.children()[0])
             message = str(data['message'])
             check_for_icon = Client.check_text(message)
             item.setText("%s: %s" % (self.members[data['username']].username, message))
             if check_for_icon is True:
                 path = os.path.dirname(os.path.abspath(__file__))
                 item.setIcon(QIcon(path + "/pictures/python.jpg"))
         except socket.timeout:
             continue
     self.sock.close()
Ejemplo n.º 49
0
    def createGroupBox(self, layout):

        group1 = QGroupBox(self)
        group1.setTitle(self.tr("KDE Themes"))
        group1.setMinimumHeight(180)
        layout.addWidget(group1)

        grLayout = QVBoxLayout(group1)
        listWidget1 = QListWidget(group1)
        grLayout.addWidget(listWidget1)

        layout.addItem(QSpacerItem(20, 40, QSizePolicy.Preferred, QSizePolicy.Preferred))


        group2 = QGroupBox(self)
        group2.setTitle(self.tr("Icon Sets"))
        group2.setMinimumHeight(140)
        group2.setMaximumHeight(150)
        layout.addWidget(group2)

        grLayout2 = QVBoxLayout(group2)
        listWidget2 = QListWidget(group2)
        listWidget2.setViewMode(QListView.IconMode)
        listWidget2.setIconSize(QSize(384, 72))
        item = QListWidgetItem(listWidget2)
        item.setIcon(QIcon(":/data/images/oxygen-set.png"))
        item.setText("Oxygen")

        item = QListWidgetItem(listWidget2)
        item.setIcon(QIcon(":/data/images/breeze-set.png"))
        item.setText("Breeze")
        item.setSelected(True)

        listWidget2.itemClicked.connect(self.iconSetSelect)

        grLayout2.addWidget(listWidget2)
Ejemplo n.º 50
0
    def createTabDesktopTheme(self):
        self.tabDesktopTheme = QWidget()
        self.tabDesktopTheme.setObjectName("tabDesktopTheme")

        self.gridLayout = QGridLayout(self.tabDesktopTheme)
        self.gridLayout.setObjectName("gridLayout")

        self.listWidgetDesktopTheme = QListWidget(self.tabDesktopTheme)
        self.listWidgetDesktopTheme.setObjectName("listWidgetDesktopTheme")
        self.listWidgetDesktopTheme.setViewMode(QListView.IconMode)
        self.listWidgetDesktopTheme.setIconSize(QSize(660, 70))
        self.gridLayout.addWidget(self.listWidgetDesktopTheme, 0, 0, 1, 1)

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        icon = QIcon(QPixmap(":/data/images/air-panel.png").scaled(QSize(660, 70), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(660, 70))
        item.setIcon(icon)
        item.panelText = "air"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/breeze-panel.png").scaled(QSize(660, 70), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(660, 70))
        item.setIcon(icon)
        item.panelText = "default"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/breeze-dark-panel.png").scaled(QSize(660, 70), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(660, 70))
        item.setIcon(icon)
        item.panelText = "breeze-dark"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/oxygen-panel.png").scaled(QSize(660, 70), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(660, 70))
        item.setIcon(icon)
        item.panelText = "oxygen"

        self.addTab(self.tabDesktopTheme, self.tr("Desktop Theme"))
Ejemplo n.º 51
0
    def createIcons(self):
        configButton = QListWidgetItem(self.contentsWidget)
        configButton.setIcon(QIcon(':/images/config.png'))
        configButton.setText("Configuration")
        configButton.setTextAlignment(Qt.AlignHCenter)
        configButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        updateButton = QListWidgetItem(self.contentsWidget)
        updateButton.setIcon(QIcon(':/images/update.png'))
        updateButton.setText("Update")
        updateButton.setTextAlignment(Qt.AlignHCenter)
        updateButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        queryButton = QListWidgetItem(self.contentsWidget)
        queryButton.setIcon(QIcon(':/images/query.png'))
        queryButton.setText("Query")
        queryButton.setTextAlignment(Qt.AlignHCenter)
        queryButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
Ejemplo n.º 52
0
    def createIcons(self):
        basicButton = QListWidgetItem(self.contentsWidget)
        basicButton.setIcon(QIcon('app/ui/images/settings.png'))
        basicButton.setText("Základní filtry")
        basicButton.setTextAlignment(Qt.AlignHCenter)
        basicButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        timeButton = QListWidgetItem(self.contentsWidget)
        timeButton.setIcon(QIcon('app/ui/images/time.png'))
        timeButton.setText("Datum a čas")
        timeButton.setTextAlignment(Qt.AlignHCenter)
        timeButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        locationButton = QListWidgetItem(self.contentsWidget)
        locationButton.setIcon(QIcon('app/ui/images/location.png'))
        locationButton.setText("Lokace")
        locationButton.setTextAlignment(Qt.AlignHCenter)
        locationButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
 def refresh(self, dir):
     # Checks the current folder to find sequences (csv files)
     self.ui.listWidget.clear()
     for file in listdir(dir):
         if path.isfile(self.curr_dir + "/" + file):
             if file.endswith(".csv"):
                 sequence = QListWidgetItem(self.ui.listWidget)
                 sequence.setText(file.replace(".csv", ""))
                 sequence.setWhatsThis('Sequence')
                 sequence.setIcon(QIcon(self.icon_dir + "/sequence.png"))
         else:
             sequence = QListWidgetItem(self.ui.listWidget)
             sequence.setText(file)
             sequence.setWhatsThis('Sequence Type')
             sequence.setIcon(QIcon(self.icon_dir + "/folder.png"))
     if dir != path.dirname(path.abspath(__file__)) + "/Sequence":
         sequence = QListWidgetItem(self.ui.listWidget)
         sequence.setText('Back')
         sequence.setWhatsThis('Back')
         sequence.setIcon(QIcon(self.icon_dir + "/back.png"))
Ejemplo n.º 54
0
    def makePopupMenu(self):
        index = self.currentIndex()
        sel = self.getSelection()
        clipboard = qApp.clipboard()

        menu = QMenu(self)

        # Get index under cursor
        pos = self.viewport().mapFromGlobal(QCursor.pos())
        mouseIndex = self.indexAt(pos)

        # Get index's title
        if mouseIndex.isValid():
            title = mouseIndex.internalPointer().title()

        elif self.rootIndex().parent().isValid():
            # mouseIndex is the background of an item, so we check the parent
            mouseIndex = self.rootIndex().parent()
            title = mouseIndex.internalPointer().title()

        else:
            title = qApp.translate("outlineBasics", "Root")

        if len(title) > 25:
            title = title[:25] + "…"

        # Open Item action
        self.actOpen = QAction(QIcon.fromTheme("go-right"),
                               qApp.translate("outlineBasics", "Open {}".format(title)),
                               menu)
        self.actOpen.triggered.connect(self.openItem)
        menu.addAction(self.actOpen)

        # Open item(s) in new tab
        if mouseIndex in sel and len(sel) > 1:
            actionTitle = qApp.translate("outlineBasics", "Open {} items in new tabs").format(len(sel))
            self._indexesToOpen = sel
        else:
            actionTitle = qApp.translate("outlineBasics", "Open {} in a new tab").format(title)
            self._indexesToOpen = [mouseIndex]

        self.actNewTab = QAction(QIcon.fromTheme("go-right"), actionTitle, menu)
        self.actNewTab.triggered.connect(self.openItemsInNewTabs)
        menu.addAction(self.actNewTab)

        menu.addSeparator()

        # Add text / folder
        self.actAddFolder = QAction(QIcon.fromTheme("folder-new"),
                                    qApp.translate("outlineBasics", "New &Folder"),
                                    menu)
        self.actAddFolder.triggered.connect(self.addFolder)
        menu.addAction(self.actAddFolder)

        self.actAddText = QAction(QIcon.fromTheme("document-new"),
                                  qApp.translate("outlineBasics", "New &Text"),
                                  menu)
        self.actAddText.triggered.connect(self.addText)
        menu.addAction(self.actAddText)

        menu.addSeparator()

        # Copy, cut, paste, duplicate
        self.actCut = QAction(QIcon.fromTheme("edit-cut"),
                              qApp.translate("outlineBasics", "C&ut"), menu)
        self.actCut.triggered.connect(self.cut)
        menu.addAction(self.actCut)

        self.actCopy = QAction(QIcon.fromTheme("edit-copy"),
                               qApp.translate("outlineBasics", "&Copy"), menu)
        self.actCopy.triggered.connect(self.copy)
        menu.addAction(self.actCopy)

        self.actPaste = QAction(QIcon.fromTheme("edit-paste"),
                                qApp.translate("outlineBasics", "&Paste"), menu)
        self.actPaste.triggered.connect(self.paste)
        menu.addAction(self.actPaste)

        # Rename / duplicate / remove items
        self.actDelete = QAction(QIcon.fromTheme("edit-delete"),
                                 qApp.translate("outlineBasics", "&Delete"),
                                 menu)
        self.actDelete.triggered.connect(self.delete)
        menu.addAction(self.actDelete)

        self.actRename = QAction(QIcon.fromTheme("edit-rename"),
                                 qApp.translate("outlineBasics", "&Rename"),
                                 menu)
        self.actRename.triggered.connect(self.rename)
        menu.addAction(self.actRename)

        menu.addSeparator()

        # POV
        self.menuPOV = QMenu(qApp.translate("outlineBasics", "Set POV"), menu)
        mw = mainWindow()
        a = QAction(QIcon.fromTheme("dialog-no"), qApp.translate("outlineBasics", "None"), self.menuPOV)
        a.triggered.connect(lambda: self.setPOV(""))
        self.menuPOV.addAction(a)
        self.menuPOV.addSeparator()

        menus = []
        for i in [qApp.translate("outlineBasics", "Main"),
                  qApp.translate("outlineBasics", "Secondary"),
                  qApp.translate("outlineBasics", "Minor")]:
            m = QMenu(i, self.menuPOV)
            menus.append(m)
            self.menuPOV.addMenu(m)

        mpr = QSignalMapper(self.menuPOV)
        for i in range(mw.mdlCharacter.rowCount()):
            a = QAction(mw.mdlCharacter.icon(i), mw.mdlCharacter.name(i), self.menuPOV)
            a.triggered.connect(mpr.map)
            mpr.setMapping(a, int(mw.mdlCharacter.ID(i)))

            imp = toInt(mw.mdlCharacter.importance(i))

            menus[2 - imp].addAction(a)

        mpr.mapped.connect(self.setPOV)
        menu.addMenu(self.menuPOV)

        # Status
        self.menuStatus = QMenu(qApp.translate("outlineBasics", "Set Status"), menu)
        # a = QAction(QIcon.fromTheme("dialog-no"), qApp.translate("outlineBasics", "None"), self.menuStatus)
        # a.triggered.connect(lambda: self.setStatus(""))
        # self.menuStatus.addAction(a)
        # self.menuStatus.addSeparator()

        mpr = QSignalMapper(self.menuStatus)
        for i in range(mw.mdlStatus.rowCount()):
            a = QAction(mw.mdlStatus.item(i, 0).text(), self.menuStatus)
            a.triggered.connect(mpr.map)
            mpr.setMapping(a, i)
            self.menuStatus.addAction(a)
        mpr.mapped.connect(self.setStatus)
        menu.addMenu(self.menuStatus)

        # Labels
        self.menuLabel = QMenu(qApp.translate("outlineBasics", "Set Label"), menu)
        mpr = QSignalMapper(self.menuLabel)
        for i in range(mw.mdlLabels.rowCount()):
            a = QAction(mw.mdlLabels.item(i, 0).icon(),
                        mw.mdlLabels.item(i, 0).text(),
                        self.menuLabel)
            a.triggered.connect(mpr.map)
            mpr.setMapping(a, i)
            self.menuLabel.addAction(a)
        mpr.mapped.connect(self.setLabel)
        menu.addMenu(self.menuLabel)

        menu.addSeparator()

        # Custom icons
        if self.menuCustomIcons:
            menu.addMenu(self.menuCustomIcons)
        else:
            self.menuCustomIcons = QMenu(qApp.translate("outlineBasics", "Set Custom Icon"), menu)
            a = QAction(qApp.translate("outlineBasics", "Restore to default"), self.menuCustomIcons)
            a.triggered.connect(lambda: self.setCustomIcon(""))
            self.menuCustomIcons.addAction(a)
            self.menuCustomIcons.addSeparator()

            txt = QLineEdit()
            txt.textChanged.connect(self.filterLstIcons)
            txt.setPlaceholderText("Filter icons")
            txt.setStyleSheet("QLineEdit { background: transparent; border: none; }")
            act = QWidgetAction(self.menuCustomIcons)
            act.setDefaultWidget(txt)
            self.menuCustomIcons.addAction(act)

            self.lstIcons = QListWidget()
            for i in customIcons():
                item = QListWidgetItem()
                item.setIcon(QIcon.fromTheme(i))
                item.setData(Qt.UserRole, i)
                item.setToolTip(i)
                self.lstIcons.addItem(item)
            self.lstIcons.itemClicked.connect(self.setCustomIconFromItem)
            self.lstIcons.setViewMode(self.lstIcons.IconMode)
            self.lstIcons.setUniformItemSizes(True)
            self.lstIcons.setResizeMode(self.lstIcons.Adjust)
            self.lstIcons.setMovement(self.lstIcons.Static)
            self.lstIcons.setStyleSheet("background: transparent; background: none;")
            self.filterLstIcons("")
            act = QWidgetAction(self.menuCustomIcons)
            act.setDefaultWidget(self.lstIcons)
            self.menuCustomIcons.addAction(act)

            menu.addMenu(self.menuCustomIcons)

        # Disabling stuff
        if not clipboard.mimeData().hasFormat("application/xml"):
            self.actPaste.setEnabled(False)

        if len(sel) == 0:
            self.actCopy.setEnabled(False)
            self.actCut.setEnabled(False)
            self.actRename.setEnabled(False)
            self.actDelete.setEnabled(False)
            self.menuPOV.setEnabled(False)
            self.menuStatus.setEnabled(False)
            self.menuLabel.setEnabled(False)
            self.menuCustomIcons.setEnabled(False)

        if len(sel) > 1:
            self.actRename.setEnabled(False)

        return menu
Ejemplo n.º 55
0
    def createTabWindowStyle(self):
        self.tabWindowStyle = QWidget()
        self.tabWindowStyle.setObjectName("tabWindowStyle")

        self.verticalLayout_6 = QVBoxLayout(self.tabWindowStyle)
        self.verticalLayout_6.setObjectName("verticalLayout_6")

        self.listWidgetWindowStyle = QListWidget(self.tabWindowStyle)
        self.listWidgetWindowStyle.setResizeMode(QListView.Adjust)
        self.listWidgetWindowStyle.setIconSize(QSize(700, 147))
        self.listWidgetWindowStyle.setViewMode(QListView.IconMode)
        self.listWidgetWindowStyle.setObjectName("listWidgetWindowStyle")

        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/data/images/breeze_deco.png"))
        item.setIcon(icon)
        item.setText("Breeze")
        item.setStyleText = "org.kde.breeze"
        item.themeText = ""
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/data/images/midna-flat_deco.png"))
        item.setIcon(icon)
        item.setText("Midna Flat")
        item.setStyleText = "org.kde.kwin.aurorae"
        item.themeText = "__aurorae__svg__MidnaFlatNarrow"
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/data/images/midna-dark_deco.png"))
        item.setIcon(icon)
        item.setText("Midna Dark")
        item.setStyleText = "org.kde.kwin.aurorae"
        item.themeText = "__aurorae__svg__MidnaDark"
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/data/images/midna-grey_deco.png"))
        item.setIcon(icon)
        item.setText("Midna Gray")
        item.setStyleText = "org.kde.kwin.aurorae"
        item.themeText = "__aurorae__svg__MidnaFlatWideGray"
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/data/images/midna-wide_deco.png"))
        item.setIcon(icon)
        item.setText("Midna Wide")
        item.setStyleText = "org.kde.kwin.aurorae"
        item.themeText = "__aurorae__svg__MidnaFlatWideBlue"
        item = QListWidgetItem(self.listWidgetWindowStyle)
        icon1 = QIcon()
        icon1.addPixmap(QPixmap(":/data/images/oxygen_deco.png"))
        item.setIcon(icon1)
        item.setText("Oxygen")
        item.setStyleText = "org.kde.oxygen"
        item.themeText = ""

        self.verticalLayout_6.addWidget(self.listWidgetWindowStyle)

        self.addTab(self.tabWindowStyle, self.tr("Window Style"))
Ejemplo n.º 56
0
    def createTabDesktopTheme(self):
        self.tabDesktopTheme = QWidget()
        self.tabDesktopTheme.setObjectName("tabDesktopTheme")
        
        self.verticalLayout_4 = QVBoxLayout(self.tabDesktopTheme)
        self.verticalLayout_4.setObjectName("verticalLayout_4")

        self.listWidgetDesktopTheme = QListWidget(self.tabDesktopTheme)
        self.listWidgetDesktopTheme.setObjectName("listWidgetDesktopTheme")
        self.listWidgetDesktopTheme.setViewMode(QListView.IconMode)
        self.listWidgetDesktopTheme.setIconSize(QSize(240, 145))
        self.listWidgetDesktopTheme.setResizeMode(QListView.Adjust)

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        icon = QIcon(QPixmap(":/data/images/air_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(240, 145))
        item.setIcon(icon)
        item.panelText = "air"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/breeze_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(240, 145))
        item.setIcon(icon)
        item.panelText = "default"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/breeze-dark_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(240, 145))
        item.setIcon(icon)
        item.panelText = "breeze-dark"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/midna_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(240, 145))
        item.setIcon(icon)
        item.panelText = "midna"
        
        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/midna-dark_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(240, 145))
        item.setIcon(icon)
        item.panelText = "midna_dark"

        item = QListWidgetItem(self.listWidgetDesktopTheme)
        item.setTextAlignment(Qt.AlignHCenter)
        icon = QIcon(QPixmap(":/data/images/oxygen_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation))
        item.setSizeHint(QSize(240, 145))
        item.setIcon(icon)
        item.panelText = "oxygen"
        
        self.verticalLayout_4.addWidget(self.listWidgetDesktopTheme)

        self.addTab(self.tabDesktopTheme, self.tr("Desktop Theme"))
Ejemplo n.º 57
0
	def __init__(self):
		self.ret_path=None
		# Create a new window

		self.window = loadUi(os.path.join(get_ui_path(),"new.ui"))

		self.win_list=windows()
		self.win_list.load()
		self.win_list.set_window(self.window,"new_simulation")

		self.window.listwidget.setIconSize(QSize(64,64))
		self.window.listwidget.clear()

		itm = QListWidgetItem( "Organic solar cell (p3htpcbm.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"icon.png")))
		self.window.listwidget.addItem(itm)

		itm = QListWidgetItem( "Organic LED (oled.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"oled.png")))
		self.window.listwidget.addItem(itm)

		itm = QListWidgetItem( "Crystalline silicon solar cell new/beta (silicon.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"si.png")))
		self.window.listwidget.addItem(itm)

		itm = QListWidgetItem( "CIGS Solar cell new/beta (cigs.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"si.png")))
		self.window.listwidget.addItem(itm)

		itm = QListWidgetItem( "a-Si solar cell new/beta (a-silicon.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"asi.png")))
		self.window.listwidget.addItem(itm)

		itm = QListWidgetItem( "polycrystalline silicon (new/beta) (silicon.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"psi.png")))
		self.window.listwidget.addItem(itm)

		itm = QListWidgetItem( "OFET (new/beta) (ofet.gpvdm)" )
		itm.setIcon(QIcon(os.path.join(get_image_file_path(),"ofet.png")))
		self.window.listwidget.addItem(itm)

		self.window.listwidget.itemDoubleClicked.connect(self.callback_next)
		self.window.next.clicked.connect(self.callback_next)
		self.window.cancel.clicked.connect(self.callback_close)
Ejemplo n.º 58
0
    def createCurveIcons(self):
        pix = QPixmap(self.m_iconSize)
        painter = QPainter()

        gradient = QLinearGradient(0, 0, 0, self.m_iconSize.height())
        gradient.setColorAt(0.0, QColor(240, 240, 240))
        gradient.setColorAt(1.0, QColor(224, 224, 224))

        brush = QBrush(gradient)

        # The original C++ code uses undocumented calls to get the names of the
        # different curve types.  We do the Python equivalant (but without
        # cheating).
        curve_types = [(n, c) for n, c in QEasingCurve.__dict__.items()
                if isinstance(c, QEasingCurve.Type) and c != QEasingCurve.Custom]
        curve_types.sort(key=lambda ct: ct[1])

        painter.begin(pix)

        for curve_name, curve_type in curve_types:
            painter.fillRect(QRect(QPoint(0, 0), self.m_iconSize), brush)

            curve = QEasingCurve(curve_type)

            if curve_type == QEasingCurve.BezierSpline:
                curve.addCubicBezierSegment(QPointF(0.4, 0.1),
                        QPointF(0.6, 0.9), QPointF(1.0, 1.0))
            elif curve_type == QEasingCurve.TCBSpline:
                curve.addTCBSegment(QPointF(0.0, 0.0), 0, 0, 0)
                curve.addTCBSegment(QPointF(0.3, 0.4), 0.2, 1, -0.2)
                curve.addTCBSegment(QPointF(0.7, 0.6), -0.2, 1, 0.2)
                curve.addTCBSegment(QPointF(1.0, 1.0), 0, 0, 0)

            painter.setPen(QColor(0, 0, 255, 64))
            xAxis = self.m_iconSize.height() / 1.5
            yAxis = self.m_iconSize.width() / 3.0
            painter.drawLine(0, xAxis, self.m_iconSize.width(),  xAxis)
            painter.drawLine(yAxis, 0, yAxis, self.m_iconSize.height())

            curveScale = self.m_iconSize.height() / 2.0;

            painter.setPen(Qt.NoPen)

            # Start point.
            painter.setBrush(Qt.red)
            start = QPoint(yAxis,
                    xAxis - curveScale * curve.valueForProgress(0))
            painter.drawRect(start.x() - 1, start.y() - 1, 3, 3)

            # End point.
            painter.setBrush(Qt.blue)
            end = QPoint(yAxis + curveScale,
                    xAxis - curveScale * curve.valueForProgress(1))
            painter.drawRect(end.x() - 1, end.y() - 1, 3, 3)

            curvePath = QPainterPath()
            curvePath.moveTo(QPointF(start))
            t = 0.0
            while t <= 1.0:
                to = QPointF(yAxis + curveScale * t,
                        xAxis - curveScale * curve.valueForProgress(t))
                curvePath.lineTo(to)
                t += 1.0 / curveScale

            painter.setRenderHint(QPainter.Antialiasing, True)
            painter.strokePath(curvePath, QColor(32, 32, 32))
            painter.setRenderHint(QPainter.Antialiasing, False)

            item = QListWidgetItem()
            item.setIcon(QIcon(pix))
            item.setText(curve_name)
            self.m_ui.easingCurvePicker.addItem(item)

        painter.end()
Ejemplo n.º 59
0
	def fill_store(self):
		self.window.listwidget.clear()
		if os.path.isdir(self.dir)==False:
			error_dlg(self,_("The directory is gone, so I can't open it."))

		
		for fl in os.listdir(self.dir):
			file_name=os.path.join(self.dir, fl)
			if os.path.isdir(file_name):
				if os.path.isfile(os.path.join(file_name,"mat.inp")):
					itm = QListWidgetItem( fl )
					itm.setIcon(self.mat_icon)
					self.window.listwidget.addItem(itm)
				else:
					show_dir=True

					#if fl=="materials":
					#	show_dir=False

					if os.path.isfile(os.path.join(file_name,"gpvdm_gui_config.inp"))==True:
						show_dir=False

					if show_dir==True:
						itm = QListWidgetItem( fl )
						itm.setIcon(self.dir_icon)
						self.window.listwidget.addItem(itm)

			else:
				#append=False
				if (file_name.endswith(".dat")==True):
					f = open(file_name, 'rb')
					text = f.readline()
					f.close()
					#text=text.encode('utf-8').strip()
					#print(text)
					#text=text.rstrip()
					if len(text)>0:
						if text[len(text)-1]==10:
							text=text[:-1]

					if text==b"#gpvdm":
						itm = QListWidgetItem( fl )
						itm.setIcon(self.dat_icon)
						self.window.listwidget.addItem(itm)

				if (file_name.endswith(".inp")==True) and self.show_inp_files==True:
					itm = QListWidgetItem( fl )
					itm.setIcon(self.inp_icon)
					self.window.listwidget.addItem(itm)

				if (file_name.endswith(".spectra")==True):
					itm = QListWidgetItem( fl )
					itm.setIcon(self.spectra_icon)
					self.window.listwidget.addItem(itm)
					
				if (file_name.endswith(".omat")==True):
					itm = QListWidgetItem( fl )
					itm.setIcon(self.mat_icon)
					self.window.listwidget.addItem(itm)

				if file_name.endswith(".xlsx")==True or file_name.endswith(".xls")==True:
					itm = QListWidgetItem( fl )
					itm.setIcon(self.xls_icon)
					self.window.listwidget.addItem(itm)

				if os.path.basename(file_name)=="sim_info.dat":
					itm = QListWidgetItem( fl )
					itm.setIcon(self.info_icon)
					self.window.listwidget.addItem(itm)
Ejemplo n.º 60
0
 def createIcons(self):
     SOButton = QListWidgetItem(self.nav_listWidget)
     SOButton.setIcon(QIcon('./images/sales.png'))
     SOButton.setText(u"销售管理")
     SOButton.setTextAlignment(Qt.AlignHCenter)
     SOButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     
     SOButton = QListWidgetItem(self.nav_listWidget)
     SOButton.setIcon(QIcon('./images/produce.png'))
     SOButton.setText(u"生产管理")
     SOButton.setTextAlignment(Qt.AlignHCenter)
     SOButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     
     POButton=QListWidgetItem(self.nav_listWidget)
     POButton.setIcon(QIcon('./images/purchase.png'))
     POButton.setText(u"采购管理")  
     POButton.setTextAlignment(Qt.AlignHCenter)
     POButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     
     EngineerButton=QListWidgetItem(self.nav_listWidget)
     EngineerButton.setIcon(QIcon('./images/engineer.png'))
     EngineerButton.setText(u"工程管理")  
     EngineerButton.setTextAlignment(Qt.AlignHCenter)
     EngineerButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     
     
     WarehouseButton=QListWidgetItem(self.nav_listWidget)
     WarehouseButton.setIcon(QIcon('./images/warehouse.png'))
     WarehouseButton.setText(u"库存管理")  
     WarehouseButton.setTextAlignment(Qt.AlignHCenter)
     WarehouseButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     
     FianceButton=QListWidgetItem(self.nav_listWidget)
     FianceButton.setIcon(QIcon('./images/fiance.png'))
     FianceButton.setText(u"财务管理")  
     FianceButton.setTextAlignment(Qt.AlignHCenter)
     FianceButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     
     HumanButton=QListWidgetItem(self.nav_listWidget)
     HumanButton.setIcon(QIcon('./images/human.png'))
     HumanButton.setText(u"人员管理")  
     HumanButton.setTextAlignment(Qt.AlignHCenter)
     HumanButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     
     CostButton=QListWidgetItem(self.nav_listWidget)
     CostButton.setIcon(QIcon('./images/cost.png'))
     CostButton.setText(u"成本管理")  
     CostButton.setTextAlignment(Qt.AlignHCenter)
     CostButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     
     BasicMessageButton=QListWidgetItem(self.nav_listWidget)
     BasicMessageButton.setIcon(QIcon('./images/basicsetting.png'))
     BasicMessageButton.setText(u"基本信息")  
     BasicMessageButton.setTextAlignment(Qt.AlignHCenter)
     BasicMessageButton.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     self.nav_listWidget.currentItemChanged.connect(self.changePage)