예제 #1
0
class LinnaeoApp(QApplication):
    """ Custom QApplication that I made to detect events. Currently not needed."""
    def __init__(self, *args):
        super().__init__(*args)
        """
        # SAVED THIS FOR LATER!
        # Read in config (linux)
        config = configparser.ConfigParser()
        try:
            config.read(str(Path.home())+"/.linnaeo/config.ini")
            # Open last used workspace automatically.
            if config['RECENTS']['LAST'] != "":
                last = config['RECENTS']['LAST']
                f = QFile(last)
                f.open(QIODevice.ReadOnly)
                model = workspace.WorkspaceModel()
                f.close()
                self.workspaceTree.setModel(model)
        except:
            print("No config file found!")
            """
        self.mode = "Light"
        self.fonts = QFontDatabase()
        self.defFontId = self.fonts.addApplicationFont(
            ':/fonts/Default-Noto.ttf')
        self.defFontId2 = self.fonts.addApplicationFont(
            ':/fonts/LiberationMono.ttf')

        # For some reason, Noto does not work on Mac or Windows. But does for SS display???
        self.defFont = QFont(self.fonts.applicationFontFamilies(self.defFontId2)[0], 10) \
            if sys.platform in ['win32', 'darwin'] else QFont(self.fonts.applicationFontFamilies(self.defFontId)[0], 10)

    def setMode(self, mode):
        self.mode = mode
예제 #2
0
파일: uiConst.py 프로젝트: ZERDICORP/hgiger
 def __init__(self):
     self.STRETCH = "STRETCH"
     self.STRETCHi = "STRETCHi"
     self.defaultSectionIcon = "client/static/assets/section.png"
     self.CursorPointer = QCursor(Qt.PointingHandCursor)
     self.CursorEdit = QCursor(Qt.IBeamCursor)
     self.sWH = GetSystemMetrics(0), GetSystemMetrics(1)
     self.RobotoLight = QFontDatabase.applicationFontFamilies(
         QFontDatabase.addApplicationFont(fontsPath.RobotoLight))[0]
     self.RobotoBold = QFontDatabase.applicationFontFamilies(
         QFontDatabase.addApplicationFont(fontsPath.RobotoBold))[0]
     QToolTip.setFont(QFont(self.RobotoLight, 10))
예제 #3
0
    def setStyle(self,
                 background_color="#555555",
                 style="mac",
                 height=80,
                 logo=None,
                 title=None):
        # 设定几何尺寸
        width = self._rootFrame.width()
        self.setGeometry(0, 0, width, height)
        # 设定属性
        minimize_btn = QPushButton(parent=self)
        minimize_btn.setGeometry(width - 100, int(height / 2 - 12), 24, 24)
        minimize_btn.setFlat(True)
        close_btn = QPushButton(parent=self)
        close_btn.setGeometry(width - 50, int(height / 2 - 12), 24, 24)
        close_btn.setFlat(True)
        if style == "mac":
            minimize_btn.setStyleSheet(
                "border-image: url('assests/minimize.svg')")
            close_btn.setStyleSheet("border-image: url('assests/close.svg')")
        else:
            # TODO
            pass
        self.setStyleSheet(
            "background-color:{};".format(background_color) +
            "border-bottom-left-radius:0px;border-bottom-right-radius:0px")

        if logo:
            logo_label = QLabel(self)
            logo_label.setGeometry(20, height / 2 - 24, 48, 48)
            logo_label.setStyleSheet("border-image: url({})".format(logo))
        if not logo and title:
            title_label = QLabel(title, self)
            title_label.setGeometry(20, 0, 200, self.height())
            title_label.setStyleSheet("color:white;")
            fontID = QFontDatabase.addApplicationFont(
                "font/Roboto-Regular-14.ttf")
            fontName = QFontDatabase.applicationFontFamilies(fontID)[0]
            font = QFont(fontName, 14, 500)
            title_label.setFont(font)
        elif logo and title:
            title_label = QLabel(title, self)
            title_label.setGeometry(100, 0, 200, self.height())
            title_label.setStyleSheet("color:white;")
            fontID = QFontDatabase.addApplicationFont(
                "font/Roboto-Regular-14.ttf")
            fontName = QFontDatabase.applicationFontFamilies(fontID)[0]
            font = QFont(fontName, 16, 500)
            title_label.setFont(font)

        close_btn.clicked.connect(self._rootFrame.close)
        minimize_btn.clicked.connect(self._rootFrame.showMinimized)
def fontawesome(font=""):
    if font == "":
        fontId = QFontDatabase.addApplicationFont("font//fontawesome-webfont.ttf")
        fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
    elif font == "fab":
        fontId = QFontDatabase.addApplicationFont("font//fa-regular-400.ttf")
        fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
    elif font == "far":
        fontId = QFontDatabase.addApplicationFont("font//fa-solid-900.ttf")
        fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
    elif font == "boot":
        fontId = QFontDatabase.addApplicationFont("font//glyphicons-halflings-regular.ttf")
        fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
    return QFont(fontName, 14)
예제 #5
0
    def icon(self, *names, **kwargs):
        """Return a QIcon object corresponding to the provided icon name."""
        options_list = kwargs.pop('options', [{}] * len(names))
        general_options = kwargs

        if len(options_list) != len(names):
            error = '"options" must be a list of size {0}'.format(len(names))
            raise Exception(error)

        if QApplication.instance() is not None:
            if self.fontname.get('mdi') is None:
                directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'fonts')
                ttf_filename = 'materialdesignicons-webfont.ttf'
                id_ = QFontDatabase.addApplicationFont(os.path.join(directory, ttf_filename))
                loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)
                if(loadedFontFamilies):
                    self.fontname['mdi'] = loadedFontFamilies[0]

            parsed_options = []
            for i in range(len(options_list)):
                specific_options = options_list[i]
                parsed_options.append(self._parse_options(specific_options,
                                                          general_options,
                                                          names[i]))
            engine = CharIconEngine(self, self.painter, parsed_options)
            return QIcon(engine)
        else:
            warnings.warn("You need to have a running "
                          "QApplication to use QtAwesome!")
            return QIcon()
예제 #6
0
 def __init__(self, size, color, number, symbol, description, parent=None):
     super(ElementButton, self).__init__(size, color, parent)
     self.number = number
     self.symbol = symbol
     self.description = description
     id_font = QFontDatabase.addApplicationFont(":YanoneKaffeesatz-Regular")
     self.family = QFontDatabase.applicationFontFamilies(id_font)[0]
예제 #7
0
def load_fonts_from_dir(directory):
    """loads available font families"""
    _families = set()
    for filename in QDir(directory).entryInfoList(["*.ttf", "*.woff", "*.woff2"]):
        _id = QFontDatabase.addApplicationFont(filename.absoluteFilePath())
        _families |= set(QFontDatabase.applicationFontFamilies(_id))
    return _families
예제 #8
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.setMinimumSize(
         int(QApplication.primaryScreen().size().width() * 0.1),
         int(QApplication.primaryScreen().size().height() * 0.2))
     self.resize(int(QApplication.primaryScreen().size().width() * 0.3),
                 int(QApplication.primaryScreen().size().height() * 0.5))
     window_width = int(QApplication.primaryScreen().size().width() * 0.3)
     id = QFontDatabase.addApplicationFont(variables.FONT_FILE)
     family = QFontDatabase.applicationFontFamilies(id)[0]
     variables.font = QFont(family, variables.FONT_SIZE)
     variables.font_small = QFont(family, variables.FONT_SIZE_SMALL)
     variables.nw = network.network()
     variables.signals = variables.DialogSignals()
     variables.signals.create_dialog.connect(self.createDialog)
     variables.signals.open_dialog.connect(self.openDialog)
     variables.signals.close_dialog.connect(self.closeDialog)
     variables.signals.message_sent.connect(self.messageSent)
     variables.nw.received.connect(self.receiveMessage)
     variables.nw.undelivered.connect(self.undelivered)
     variables.nw.delivered.connect(self.delivered)
     variables.nw.read.connect(self.read)
     variables.nw.reconnect.connect(self.clientReconnected)
     self.dialogs = []
     self.dialog_menu = DialogList()
     self.main_widget = QStackedWidget()
     self.main_widget.addWidget(self.dialog_menu)
     self.setCentralWidget(self.main_widget)
     self.setWindowTitle(variables.APP_NAME)
     self.setWindowIcon(QIcon(variables.LOGO_IMG))
     self.dialog_menu.ip_input.setFocus()
예제 #9
0
 def set_font(self, font_name, font_size):
     selected_font = QFontDatabase.applicationFontFamilies(
         self.font_db[font_name])
     font = QFont()
     font.setFamily(selected_font[0])
     font.setPointSize(int(font_size))
     return font
예제 #10
0
    def __init__(self):
        #Constructor
        super().__init__()

        font_db = QFontDatabase()
        font_id = font_db.addApplicationFont("Fonts\Quicksand.otf")
        families = font_db.applicationFontFamilies(font_id)
예제 #11
0
    def __init__(self, parent):
        super().__init__()
        self.setParent(parent)
        self.resize(parent.width() / 2, parent.height() / 2)
        self.setMinimumSize(parent.width() / 3, parent.height() / 2)
        self.setMaximumSize(parent.width() / 3 + 1, parent.height() / 2 + 1)
        self.setStyleSheet("background-color:black")
        self.setAutoFillBackground(True)

        id = QFontDatabase.addApplicationFont(
            "ressources/QuiverItal Regular.ttf")
        family = QFontDatabase.applicationFontFamilies(id)[0]

        self.font = QFont(family, 50)

        self.gridLayout = QGridLayout(self)
        self.gridLayout.setAlignment(Qt.AlignTop)

        self.drawTop()
        self.drawBottom()
        self.drawMeteo()

        eventSignals.time.connect(self.updateTime)
        eventSignals.meteoCondition.connect(self.updateMeteo)

        self.setLayout(self.gridLayout)
        self.show()
예제 #12
0
파일: __main__.py 프로젝트: alerque/Slice
    def setUIAppIconTitle(self):
        monoton_id = QFontDatabase.addApplicationFont(
            ":/font/Monoton-Regular.subset.ttf"
        )
        font_family = QFontDatabase.applicationFontFamilies(monoton_id)[0]
        monoton = QFont(font_family)
        outerHBox = QHBoxLayout()
        titleLabel = QLabel("<h1>slice</h1>")
        titleLabel.setStyleSheet("QLabel { font-size: 36px;}")
        titleLabel.setFont(monoton)
        titleLabel.setAlignment(Qt.AlignLeft | Qt.AlignBottom)
        iconLabel = QLabel()
        # note: commented block below shows how to use
        #       svg embedded as a Python string literal
        #       for QImage instantiation. The current
        #       approach is better
        # svg_bytes = bytearray(svg_icon, encoding="utf-8")
        # qimage = QImage.fromData(svg_bytes)
        qimage = QImage(":/img/slice-icon.svg")
        pixmap = QPixmap.fromImage(qimage)
        iconLabel.setPixmap(pixmap)
        iconLabel.setFixedHeight(60)
        iconLabel.setFixedWidth(75)
        outerHBox.addWidget(iconLabel)
        outerHBox.addWidget(titleLabel)

        # add widget to main layout
        self.main_layout.addLayout(outerHBox)
예제 #13
0
    def initUI(self):
        fontPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'font/Audiowide-Regular.ttf')
        font_id = QFontDatabase.addApplicationFont(fontPath)
        families = QFontDatabase.applicationFontFamilies(font_id)
        font = QFont("Audiowide")
        self.setFont(font)

        self.btnAction = QPushButton('Download Engine', self)
        self.btnAction.clicked.connect(self.OnBtnClick)
        self.btnAction.resize(self.btnAction.sizeHint())
        self.btnAction.move(20, 145)
        self.btnAction.setFont(font)

        self.lblStatus = QLabel('Status label', self)
        self.lblStatus.resize(self.btnAction.sizeHint())
        self.lblStatus.setText("")
        self.lblStatus.setContentsMargins(0,0,0,0);
        self.lblStatus.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        self.lblStatus.move(190, 150)
        self.lblStatus.setFont(font)
        #self.lblStatus.setStyleSheet("border: 1px solid black;");
        dse = QGraphicsDropShadowEffect(self)
        dse.setBlurRadius(10)
        dse.setColor(QColor("#FFEEEE"))
        dse.setOffset(4,4)
        self.lblStatus.setGraphicsEffect(dse)

        self.pbDownload = QProgressBar(self)
        self.pbDownload.setGeometry(30, 40, 400, 25)
        self.step = 0

        self.setGeometry(300, 300, 550, 250)
        self.setStyleSheet("QMainWindow {border-image: url(data/background.jpg) 0 0 0 0 stretch stretch;}")
        self.setObjectName("Window")
        self.setWindowTitle(self.config.game_title)
        self.show()

        self.dl = SpringDownloader()
        self.dl.downloadStarted.connect(self.OnDownloadStarted)
        self.dl.downloadFinished.connect(self.OnDownloadFinished)
        self.dl.downloadFailed.connect(self.OnDownloadFailed)
        self.dl.downloadProgress.connect(self.OnDownloadProgress)
        self.launcher = EngineLauncher()
        self.launcher.lobbyClosed.connect(self.OnLobbyClosed)

        self.games = copy.deepcopy(self.config.games)
        self.maps = copy.deepcopy(self.config.maps)
        self.engines = copy.deepcopy(self.config.engines)

        if self.engines and len(self.engines) > 0:
            self.launcher.VERSION_STRING = self.engines[0]

        self.actions = ["autoupdate", "packages", "start"]
        if self.config.no_downloads:
            self.actions = ["start"]
        self.DisplayNextAction()
        if self.config.auto_download:
            self.btnAction.setEnabled(False)
            self.MaybeNextStep()
예제 #14
0
 def load_font(path: str) -> Optional[QFont]:
     escaped_path = os.path.sep.join(path.split('/'))
     _id = QFontDatabase.addApplicationFont(ResourceManager.get_resource_location("font", escaped_path))
     if _id == -1:
         print(f"Unable to load font '{path}'")
         return None
     fontstr = QFontDatabase.applicationFontFamilies(_id)[0]
     return QFont(fontstr, 0)
예제 #15
0
 def __init__(self, qtpy):
     super().__init__(qtpy)
     self.version = "0.1.0"
     self.qapplication = QApplication(sys.argv)
     self.windows = []
     res_path = Path(__file__).parent.parent.parent.parent.joinpath("res")
     comfortaa_id = QFontDatabase.addApplicationFont(
         str(res_path.joinpath("Comfortaa-Regular.ttf")))
     self.comfortaa_font_family = QFontDatabase.applicationFontFamilies(
         comfortaa_id)[0]
     roboto_id = QFontDatabase.addApplicationFont(
         str(res_path.joinpath("Roboto-Regular.ttf")))
     self.roboto_font_family = QFontDatabase.applicationFontFamilies(
         roboto_id)[0]
     self.config = UIConfig()
     self.config.read_data_file(STD_PATH_GUI_CONFIG)
     self.theme = load_theme(self.config.get("theme_file"))
예제 #16
0
 def initFont(self):
     """初始化字体"""
     # 使用本地字体
     fontID = QFontDatabase.addApplicationFont('./Font/Consolas Italic.ttf')
     self.font = QFont()
     self.font.setFamily(QFontDatabase.applicationFontFamilies(fontID)[0])
     self.font.setItalic(True)  # 斜体
     self.font.setBold(True)  # 粗体
     self.font.setPixelSize(40)  # 字体大小
예제 #17
0
 def load_icon_font(cls):
     '''
     加载图标字体
     '''
     fontawesome_id = QFontDatabase().addApplicationFont(
         ':font/fontawesome-webfont.ttf')
     fontawesome_name = QFontDatabase.applicationFontFamilies(
         fontawesome_id)[0]
     cls.iconFontNames['fontawesome'] = fontawesome_name
예제 #18
0
 def __init__(self):
     super().__init__()
     anime_bk_pic_path = './source/pic/anime_bk.png'
     search_1_pic_path = './source/pic/next.png'
     search_2_pic_path = './source/pic/next_1.png'
     search_3_pic_path = './source/pic/next_2.png'
     hgzy_font_path = './source/font/HGZYT_CNKI.TTF'
     rem_ico_path = './source/pic/rem.png'
     self.pix = QPixmap(anime_bk_pic_path)
     self.resize(self.pix.width(),self.pix.height())
     self.pix = self.pix.scaled(int(self.pix.width()), int(self.pix.height()))
     self.setMask(self.pix.mask())
     screen = QDesktopWidget().screenGeometry()
     self.move((screen.width() - self.pix.width()) / 2, (screen.height() - self.pix.height()) / 2)
     self.setWindowFlags(Qt.FramelessWindowHint)  # | QtCore.Qt.WindowStaysOnTopHint
     self.setAttribute(Qt.WA_TranslucentBackground) # 窗口透明抗锯齿
     rem_icon = QIcon(QPixmap(rem_ico_path))
     self.setWindowIcon(rem_icon)
     self.m_DragPosition = None
     fontId = QFontDatabase.addApplicationFont(hgzy_font_path)
     fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
     self.animelist = QDListWidget(self)
     self.animelist.setObjectName('AnimeListWidget')
     self.animelist.setGeometry(17,280,self.pix.width()-34,self.pix.height()-280-50)
     self.animelist.setStyleSheet('#AnimeListWidget{background:transparent;}')
     self.animelist.setFont(QFont(fontName,15,QFont.Light))
     self.animelist.setIconSize(QSize(100,100))
     self.InitData()
     ver = Version()
     self.version = QDLabel(self, ver.cur_link)
     self.version.setObjectName('VersionLabel')
     self.version.setGeometry(15, self.pix.height() - 75, 600, 100)
     self.version.setText('当前数据库版本号:' + ver.cur_version)
     if ver.judge_version():
         self.version.setToolTip('数据库为最新版本,无需更新')
     else:
         self.version.setToolTip('数据库版本已过期,请自行下载新数据库.(双击获取下载链接)')
     self.version.setFont(QFont(fontName,10,QFont.Light))
     self.search = QPushButton(self)
     self.search.setObjectName('Search')
     self.search.setStyleSheet("#Search{border-image: url(%s)}"
                               "#Search:hover{border-image: url(%s)}" 
                               "#Search:pressed{border-image: url(%s)}"
                               % (search_1_pic_path,search_2_pic_path,search_3_pic_path))
     self.search.setGeometry(self.pix.width()-self.search.width(),self.pix.height()-self.search.height()-10
                             ,self.search.width()-20,self.search.height())
     self.choose = Choose(self.x()+self.width(),self.y()+self.height())
     self.choose_show = False
     self.choose_info = {}
     self.search.clicked.connect(self.SearchBt)
     self.detail = Detail(self.x(),self.y())
     self.detail_show = False
     self.animelist.itemDoubleClicked.connect(self.DetailBt)
     self.animelist.installEventFilter(self)
     self.rightclick = Rightclick()
     self.animeshow = False
 def __init__(self):
     super(MgrHelper, self).__init__()
     fontFile = resources_folder + '/fontawesome-webfont.ttf'
     #fontFile='fontawesome-webfont.ttf'
     fontId = QFontDatabase.addApplicationFont(fontFile)
     fontName = QFontDatabase.applicationFontFamilies(fontId)
     self.iconFont = QFont(fontName[0])  #图形字体
     self.mousePressed = False
     #给QApplication安装事件过滤器,所有对象的每个事件在被送到其它事件过滤器前都要送到eventFilter
     QApplication.instance().installEventFilter(self)
예제 #20
0
def _load_font(name, size=8):
    """Load a TTF font."""
    if name in _FONTS:
        return _FONTS[name]
    font_id = QFontDatabase.addApplicationFont(str(_static_abs_path(name)))
    font_db = QFontDatabase()
    font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
    font = font_db.font(font_family, None, size)
    _FONTS[name] = font
    return font
예제 #21
0
 def __init__(self):
     super().__init__()
     follow_bk_pic_path = './source/pic/follow_bk.png'
     search_1_pic_path = './source/pic/next.png'
     search_2_pic_path = './source/pic/next_1.png'
     search_3_pic_path = './source/pic/next_2.png'
     hgzy_font_path = './source/font/HGZYT_CNKI.TTF'
     rem_ico_path = './source/pic/rem.png'
     self.pix = QPixmap(follow_bk_pic_path)
     self.resize(self.pix.width(), self.pix.height())
     self.pix = self.pix.scaled(int(self.pix.width()),
                                int(self.pix.height()))
     self.setMask(self.pix.mask())
     screen = QDesktopWidget().screenGeometry()
     self.move((screen.width() - self.pix.width()) / 2,
               (screen.height() - self.pix.height()) / 2)
     self.setWindowFlags(
         Qt.FramelessWindowHint)  # | QtCore.Qt.WindowStaysOnTopHint
     self.setAttribute(Qt.WA_TranslucentBackground)  # 窗口透明抗锯齿
     rem_icon = QIcon(QPixmap(rem_ico_path))
     self.setWindowIcon(rem_icon)
     self.m_DragPosition = None
     fontId = QFontDatabase.addApplicationFont(hgzy_font_path)
     fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
     self.followlist = QDListWidget(self)
     self.followlist.setObjectName('FollowListWidget')
     self.followlist.setGeometry(17, 280,
                                 self.pix.width() - 34,
                                 self.pix.height() - 280 - 50)
     self.followlist.setStyleSheet(
         '#FollowListWidget{background:transparent;}')
     self.followlist.setFont(QFont(fontName, 15, QFont.Light))
     self.followlist.setIconSize(QSize(100, 100))
     self.ShowData()
     self.search = QPushButton(self)
     self.search.setObjectName('Search')
     self.search.setStyleSheet(
         "#Search{border-image: url(%s)}"
         "#Search:hover{border-image: url(%s)}"
         "#Search:pressed{border-image: url(%s)}" %
         (search_1_pic_path, search_2_pic_path, search_3_pic_path))
     self.search.setGeometry(self.pix.width() - self.search.width(),
                             self.pix.height() - self.search.height() - 10,
                             self.search.width() - 20, self.search.height())
     self.choose = Choose(self.x() + self.width(), self.y() + self.height())
     self.choose_show = False
     self.choose_info = {}
     self.search.clicked.connect(self.SearchBt)
     self.detail = Detail(self.x(), self.y())
     self.detail_show = False
     self.followlist.itemDoubleClicked.connect(self.DetailBt)
     self.followlist.installEventFilter(self)
     self.rightclick = FollowRightclick()
     self.followshow = False
예제 #22
0
 def add_fonts(self):
     fontdir = os.path.join(system.execpath, "fonts")
     # filenames = os.listdir(fontdir)
     filenames = ["fa-solid-900.ttf"]
     for filename in filenames:
         suffix = filename.split(".")[-1].lower()
         if suffix in ["ttf"]:
             filepath = os.path.join(fontdir, filename)
             fontId = QFontDatabase.addApplicationFont(filepath)
             print("Added font:",
                   QFontDatabase.applicationFontFamilies(fontId))
예제 #23
0
    def __init__(self):
        super(Window, self).__init__()
        BASE_DIR = os.path.dirname(os.path.abspath(__file__))

        font_id = QFontDatabase.addApplicationFont(
            os.path.join(BASE_DIR,
                         "../../resources/font/fontawesome-webfont.ttf"))
        if font_id is not -1:
            fontName = QFontDatabase.applicationFontFamilies(font_id)[0]
            self.font = QFont(fontName, 32)
        self.home()
예제 #24
0
    def load_font(self):
        if QApplication.instance() is None:
            logger.warning('No QApplication instance found')
            return

        font_file = QFile(':font/awesome')
        if font_file.open(QFile.ReadOnly):
            idf = QFontDatabase.addApplicationFontFromData(
                QByteArray(font_file.readAll()))
            font_file.close()

            self.font_name = QFontDatabase.applicationFontFamilies(idf)[0]
예제 #25
0
    def setup_ui(self):
        shadow_effect = QGraphicsDropShadowEffect()
        shadow_effect.setBlurRadius(1)
        shadow_effect.setColor(QColor(200, 200, 200))
        shadow_effect.setOffset(0, 0)
        self.shadow_effect = shadow_effect
        self.setGraphicsEffect(self.shadow_effect)
        self.setStyleSheet(
            "MFrame{margin:0px;padding:0px;border:1px solid;"
            "border-color:rgb(220,220,220);background-color:white}")
        self.setGeometry(100, 100, 1366, 768)
        self.top_bar = MFrame(self)
        self.top_bar.setGeometry(0, 0, 1366, 80)

        font_id = QFontDatabase.addApplicationFont(
            "font/Roboto-Regular-14.ttf")
        font_name = QFontDatabase.applicationFontFamilies(font_id)[0]
        font = QFont(font_name, 14, 1)
        config_label = QLabel("Configuration", self.top_bar)
        config_label.setGeometry(1030, 1, 150, 78)
        config_label.setStyleSheet("color: rgb(100, 100, 100)")
        config_label.setFont(font)

        self.line_label = QLabel(self.top_bar)
        self.line_label.setStyleSheet("background-color:rgb(80, 80, 80)")
        self.line_label.setGeometry(50, 76, 200, 4)

        view_box = MFrame(self)
        view_box.setGeometry(0, 80, 1000, 688)
        view_box.setStyleSheet("border-top:none;background-color:#fafafa")
        self.view_box = view_box
        self.fillViewBox()

        self.buildupTopBtns()
        self.line_label.raise_()

        options = MFrame(self)
        options.setGeometry(1000, 80, 366, 688)
        options.setStyleSheet("border-top:none;border-left:none;")

        option_label = QLabel("Options", options)
        option_label.setGeometry(30, 30, 150, 60)
        font = QFont(font_name, 13, 1)
        option_label.setStyleSheet("color: rgb(100, 100, 100)")
        option_label.setFont(font)

        self.shadow_animation = QPropertyAnimation(self)
        self.shadow_animation.setTargetObject(self.shadow_effect)
        self.shadow_animation.setPropertyName(b"blurRadius")
        self.shadow_animation.setStartValue(1)
        self.shadow_animation.setEndValue(40)
        self.shadow_animation.setDuration(500)
예제 #26
0
    def __init__(self):
        super(MainWindow, self).__init__()

        font_id = QFontDatabase.addApplicationFont("fontawesome-webfont.ttf")

        if font_id is not -1:
            font_db = QFontDatabase()
            self.font_styles = font_db.styles('FontAwesome')
            self.font_families = QFontDatabase.applicationFontFamilies(font_id)
            print(self.font_styles, self.font_families)
            for font_family in self.font_families:
                self.font = font_db.font(font_family, self.font_styles[0], 18)
        self.home()
예제 #27
0
    def __init__(self, parent):
        QLineEdit.__init__(self)
        self.next_texts = []
        self.timer = QTimer()
        self.timer.setInterval(350)
        self.timer.timeout.connect(self.showNextText)

        self.ubuntu_font = QFont(
            QFontDatabase.applicationFontFamilies(0)[0], 8)
        self.ubuntu_font_cond = QFont(
            QFontDatabase.applicationFontFamilies(1)[0], 8)
        self.ubuntu_font.setBold(True)
        self.ubuntu_font_cond.setBold(True)

        self.basecolor = self.palette().base().color().name()
        self.bluecolor = self.palette().highlight().color().name()

        self.last_status_time = 0.0

        # ui_client_slot.py will display "stopped" status.
        # we need to not stay on this status text
        # especially at client switch because widget is recreated.
        self._first_text_done = False
예제 #28
0
def set_font(font, size=None):
    if size is None:
        default_size = 15
        size = default_size

    if font == 'Roboto':
        id = QFontDatabase.addApplicationFont(
            "resources/fonts/Roboto-Light.ttf")
    elif font == 'Antonio':
        id = QFontDatabase.addApplicationFont(
            "resource/fonts/Antonio-Regular.ttf")
    _fontstr = QFontDatabase.applicationFontFamilies(id)[0]
    font = QFont(_fontstr, size)

    return font
예제 #29
0
    def font(cls, path=''):
        """
        初始化字体
        """
        FontPath = os.path.abspath(
            os.path.join(ThemeManager.ThemeDir, ThemeManager.ThemeName,
                         'font.otf')).replace('\\', '/')

        FontId = QFontDatabase.addApplicationFont(FontPath)
        FontFamilies = QFontDatabase.applicationFontFamilies(FontId)

        if len(FontFamilies) != 0:
            FontName = FontFamilies[0]
            return QFont(FontName, 30)
        else:
            return None
예제 #30
0
    def loadFontFamilyFromTTF(self):
        if not self.isLoaded:
            # load custom font
            dir = os.path.dirname(os.path.abspath(__file__))
            fontId = QFontDatabase.addApplicationFont(
                dir + '/font/SourceCodePro-Medium.ttf')
            if fontId == -1:
                print('font load failed......')
            loadedFontFamilies = QFontDatabase.applicationFontFamilies(fontId)
            if len(loadedFontFamilies) != 0:
                self.customFontName = loadedFontFamilies[0]

            self._commentFont = QFont("Helvetica [Cronyx]", 13)
            self._freeCommentFont = QFont("Helvetica [Cronyx]", 48)

            self.isLoaded = True
예제 #31
0
 def __init__(self, ttfFile, mapFile):
     """
     :param ttfFile:            ttf字体文件路径
     :param mapFile:            ttf字体文件对应的字符映射 json格式
     """
     fontId = QFontDatabase.addApplicationFont(ttfFile)
     fontFamilies = QFontDatabase.applicationFontFamilies(fontId)
     if fontFamilies:
         self._font = QFont(fontFamilies[0])
         self.fontMap = json.loads(open(mapFile, 'rb').read().decode(
             encoding='utf_8', errors='ignore'),
                                   encoding='utf_8',
                                   object_hook=self.object_hook)
     else:
         self._font = QFont()
         self.fontMap = {}
예제 #32
0
    def load_font(self, prefix, ttf_filename, charmap_filename, directory=None):
        """Loads a font file and the associated charmap

        If `directory` is None, the files will be looked up in ./fonts/

        Arguments
        ---------
        prefix: str
            prefix string to be used when accessing a given font set
        ttf_filename: str
            ttf font filename
        charmap_filename: str
            charmap filename
        directory: str or None, optional
            directory for font and charmap files
        """

        def hook(obj):
            result = {}
            for key in obj:
                result[key] = unichr(int(obj[key], 16))
            return result

        if directory is None:
            directory = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'fonts')

        with open(os.path.join(directory, charmap_filename), 'r') as codes:
            self.charmap[prefix] = json.load(codes, object_hook=hook)

        id_ = QFontDatabase.addApplicationFont(os.path.join(directory, ttf_filename))

        loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)

        if loadedFontFamilies:
            self.fontname[prefix] = loadedFontFamilies[0]
        else:
            print('Font is empty')
예제 #33
0
파일: app.py 프로젝트: OpenShot/openshot-qt
    def __init__(self, *args, mode=None):
        QApplication.__init__(self, *args)

        # Log some basic system info
        try:
            v = openshot.GetVersion()
            log.info("openshot-qt version: %s" % info.VERSION)
            log.info("libopenshot version: %s" % v.ToString())
            log.info("platform: %s" % platform.platform())
            log.info("processor: %s" % platform.processor())
            log.info("machine: %s" % platform.machine())
            log.info("python version: %s" % platform.python_version())
            log.info("qt5 version: %s" % QT_VERSION_STR)
            log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
        except:
            pass

        # Setup application
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        self.settings.load()

        # Init and attach exception handler
        from classes import exceptions
        sys.excepthook = exceptions.ExceptionHandler

        # Init translation system
        language.init_language()

        # Detect minimum libopenshot version
        _ = self._tr
        libopenshot_version = openshot.GetVersion().ToString()
        if mode != "unittest" and libopenshot_version < info.MINIMUM_LIBOPENSHOT_VERSION:
            QMessageBox.warning(None, _("Wrong Version of libopenshot Detected"),
                                      _("<b>Version %(minimum_version)s is required</b>, but %(current_version)s was detected. Please update libopenshot or download our latest installer.") %
                                {"minimum_version": info.MINIMUM_LIBOPENSHOT_VERSION, "current_version": libopenshot_version})
            # Stop launching and exit
            sys.exit()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Start libopenshot logging thread
        self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
        self.logger_libopenshot.start()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            try:
                log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
                font = QFont(font_family)
                font.setPointSizeF(10.5)
                QApplication.setFont(font)
            except Exception as ex:
                log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(104, 104, 104))
            self.setPalette(darkPalette)
            self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow(mode)

        # Reset undo/redo history
        self.updates.reset()
        self.window.updateStatusChanged(False, False)

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.OpenProjectSignal.emit(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)
        else:
            # Recover backup file (this can't happen until after the Main Window has completely loaded)
            self.window.RecoverBackup.emit()
예제 #34
0
파일: app.py 프로젝트: ghisvail/openshot-qt
    def __init__(self, *args):
        QApplication.__init__(self, *args)

        # Setup appication
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        try:
            self.settings.load()
        except Exception as ex:
            log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
            exit()

        # Init translation system
        language.init_language()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
            font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
            font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
            font = QFont(font_family)
            font.setPointSizeF(10.5)
            QApplication.setFont(font)

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            self.setPalette(darkPalette)
            self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow()
        self.window.show()

        # Load new/blank project (which sets default profile)
        self.project.load("")

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.open_project(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)
예제 #35
0
    def load_font(self, prefix, ttf_filename, charmap_filename, directory=None):
        """Loads a font file and the associated charmap.

        If ``directory`` is None, the files will be looked for in ``./fonts/``.

        Parameters
        ----------
        prefix: str
            Prefix string to be used when accessing a given font set
        ttf_filename: str
            Ttf font filename
        charmap_filename: str
            Charmap filename
        directory: str or None, optional
            Directory for font and charmap files
        """

        def hook(obj):
            result = {}
            for key in obj:
                result[key] = unichr(int(obj[key], 16))
            return result

        if directory is None:
            directory = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'fonts')

        # Load font
        if QApplication.instance() is not None:
            id_ = QFontDatabase.addApplicationFont(os.path.join(directory,
                                                                ttf_filename))
            loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)
            if(loadedFontFamilies):
                self.fontname[prefix] = loadedFontFamilies[0]
            else:
                raise FontError(u"Font at '{0}' appears to be empty. "
                                "If you are on Windows 10, please read "
                                "https://support.microsoft.com/"
                                "en-us/kb/3053676 "
                                "to know how to prevent Windows from blocking "
                                "the fonts that come with QtAwesome.".format(
                                        os.path.join(directory, ttf_filename)))

            with open(os.path.join(directory, charmap_filename), 'r') as codes:
                self.charmap[prefix] = json.load(codes, object_hook=hook)

            # Verify that vendorized fonts are not corrupt
            if not SYSTEM_FONTS:
                md5_hashes = {'fontawesome-webfont.ttf':
                              'b06871f281fee6b241d60582ae9369b9',
                              'elusiveicons-webfont.ttf':
                              '207966b04c032d5b873fd595a211582e'}
                ttf_hash = md5_hashes.get(ttf_filename, None)
                if ttf_hash is not None:
                    hasher = hashlib.md5()
                    with open(os.path.join(directory, ttf_filename),
                              'rb') as f:
                        content = f.read()
                        hasher.update(content)
                    ttf_calculated_hash_code = hasher.hexdigest()
                    if ttf_calculated_hash_code != ttf_hash:
                        raise FontError(u"Font is corrupt at: '{0}'".format(
                                        os.path.join(directory, ttf_filename)))
예제 #36
0
    def __init__(self, *args, mode=None):
        QApplication.__init__(self, *args)

        # Log some basic system info
        try:
            v = openshot.GetVersion()
            log.info("openshot-qt version: %s" % info.VERSION)
            log.info("libopenshot version: %s" % v.ToString())
            log.info("platform: %s" % platform.platform())
            log.info("processor: %s" % platform.processor())
            log.info("machine: %s" % platform.machine())
            log.info("python version: %s" % platform.python_version())
            log.info("qt5 version: %s" % QT_VERSION_STR)
            log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
        except:
            pass

        # Setup appication
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        try:
            self.settings.load()
        except Exception as ex:
            log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
            exit()

        # Init translation system
        language.init_language()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Start libopenshot logging thread
        self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
        self.logger_libopenshot.start()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set unique install id (if blank)
        if not self.settings.get("unique_install_id"):
            self.settings.set("unique_install_id", str(uuid4()))

            # Track 1st launch metric
            import classes.metrics
            classes.metrics.track_metric_screen("initial-launch-screen")

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            try:
                log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
                font = QFont(font_family)
                font.setPointSizeF(10.5)
                QApplication.setFont(font)
            except Exception as ex:
                log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(104, 104, 104))
            self.setPalette(darkPalette)
            self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow(mode)

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.open_project(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)

        # Reset undo/redo history
        self.updates.reset()
        self.window.updateStatusChanged(False, False)
예제 #37
0
파일: report.py 프로젝트: wdbm/report
class Report(QMainWindow):

    def __init__(self):

        super(Report, self).__init__()
        self.status_view   = "window"
        self.status_colors = "light"
        self.font_size     = 22
        self.font_database = QFontDatabase()

        # add font cmtex9
        self.font_file_cmtex9 = "cmtex9.ttf"
        self.font_identifier_cmtex9 = QFontDatabase.addApplicationFont(
            self.font_file_cmtex9
        )
        self.fontFamilyName_cmtex9 = self.font_database.applicationFontFamilies(
            self.font_identifier_cmtex9
        )[0]
        self.update_font()

        self.initialise_UI()

    def update_font(self):

        # add font cmtex9
        self.font_cmtex9 = QFont(self.fontFamilyName_cmtex9, self.font_size)
        # add font Courier Prime
        self.font_CourierPrime = QFont("Courier Prime", self.font_size)
        # set default font
        self.font_current = self.font_cmtex9
        self.font_current.setFixedPitch(True)
        self.setFont(self.font_current)

    def initialise_UI(self):

        action_toggle_view = QAction("toggle view", self)
        action_toggle_view.setShortcut("F11")
        action_toggle_view.setStatusTip("toggle fullscreen/window view")
        action_toggle_view.triggered.connect(self.toggle_view)

        action_toggle_colors = QAction("toggle colors", self)
        action_toggle_colors.setShortcut("Ctrl+D")
        action_toggle_colors.setStatusTip("toggle light/dark colors")
        action_toggle_colors.triggered.connect(self.toggle_colors)

        action_set_font_size = QAction("set font size", self)
        action_set_font_size.setShortcut("Ctrl+T")
        action_set_font_size.setStatusTip("set font size")
        action_set_font_size.triggered.connect(self.set_font_size)

        action_new = QAction("new", self)
        action_new.setShortcut("Ctrl+N")
        action_new.setStatusTip("create new file")
        action_new.triggered.connect(self.new_file)

        action_save = QAction("save", self)
        action_save.setShortcut("Ctrl+S")
        action_save.setStatusTip("save current file")
        action_save.triggered.connect(self.save_file)

        action_open = QAction("open", self)
        action_open.setShortcut("Ctrl+O")
        action_open.setStatusTip("open a file")
        action_open.triggered.connect(self.open_file)

        action_close = QAction("close", self)
        action_close.setShortcut("Ctrl+W")
        action_close.setStatusTip("close report")
        action_close.triggered.connect(self.close)

        menu_bar = self.menuBar()
        file_menu = menu_bar.addMenu("&file")
        file_menu.addAction(action_toggle_view)
        file_menu.addAction(action_toggle_colors)
        file_menu.addAction(action_set_font_size)
        file_menu.addAction(action_new)
        file_menu.addAction(action_save)
        file_menu.addAction(action_open)
        file_menu.addAction(action_close)

        self.text = QTextEdit(self)
        self.text.setStyleSheet(
            """
            QTextEdit{
                color: #000000;
                background-color: #ffffff;
            }
            """
        )

        self.setCentralWidget(self.text)
        self.setGeometry(300, 300, 300, 300)
        self.showMaximized()
        self.setWindowTitle("report")
        self.show()

    def toggle_view(self):

        if self.status_view == "window":

            self.showFullScreen()
            self.status_view = "fullscreen"

            return

        if self.status_view == "fullscreen":

            self.showMaximized()
            self.status_view = "window"

            return

    def toggle_colors(self):

        if self.status_colors == "light":

            self.text.setStyleSheet(
                """
                QTextEdit{
                    color: #ffffff;
                    background-color: #000000;
                }
                """
            )
            self.status_colors = "dark"

            return

        if self.status_colors == "dark":

            self.text.setStyleSheet(
                """
                QTextEdit{
                    color: #000000;
                    background-color: #ffffff;
                }
                """
            )
            self.status_colors = "light"

            return

    def set_font_size(self):

        font_size, ok = QInputDialog.getText(
            self,
            "font size", 
            "enter font size:"
        )
        if ok is True:
            self.font_size = int(font_size)
            self.update_font()

    def new_file(self):

        self.text.clear()

    def save_file(self):

        filename = QFileDialog.getSaveFileName(
            self,
            "save file",
            os.getenv("HOME")
        )[0]

        if filename != u"":

            with open(filename, "w") as file_save:
                file_data = self.text.toPlainText()
                file_save.write(file_data)

    def open_file(self):

        filename = QFileDialog.getOpenFileName(
            self,
            "open file",
            os.getenv("HOME")
        )[0]

        with open(filename, "r") as file_open:
            file_data = file_open.read()
            self.text.setText(file_data)