Ejemplo n.º 1
0
def create_toaster(first_line: str = 'Beskar',
                   second_line: str = 'An update for Beskar is available.',
                   new_version: str = None,
                   third_line: str = None,
                   update_action: bool = True,
                   whats_new: bool = True,
                   toaster_type=zroya.TemplateType.ImageAndText4):
    if zroya_init():
        toaster = zroya.Template(toaster_type)
        toaster.setFirstLine(first_line)
        toaster.setSecondLine(second_line)
        if third_line:
            toaster.setThirdLine(third_line)
        else:
            if new_version is None:
                raise TypeError(
                    'new_version and third_line cannot both be None.')
            else:
                toaster.setThirdLine(f'{__version__} ➡ {new_version}')

        if darkdetect.isDark():
            icon_loc = get_file('beskar-icon-white.png')
        else:
            icon_loc = get_file('beskar-icon.png')
        toaster.setImage(icon_loc)

        if update_action:
            toaster.addAction('Update')
        if whats_new:
            toaster.addAction("What's New?")

        return toaster
Ejemplo n.º 2
0
    def __init__(self, parent, image_file):
        super().__init__(parent)

        img = wx.StaticBitmap(self,
                              id=wx.ID_ANY,
                              bitmap=wx.Image(image_file).Scale(
                                  128, 128).ConvertToBitmap())
        txt = wx.StaticText(
            self,
            id=wx.ID_ANY,
            label="\nDrop here PDF files you want to process...",
            style=wx.ALIGN_CENTRE_HORIZONTAL)
        txt.SetForegroundColour((96, 96, 96))
        txt.SetFont(
            wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))

        v_sizer = wx.BoxSizer(wx.VERTICAL)
        v_sizer.AddStretchSpacer()
        v_sizer.Add(img, proportion=0, flag=wx.CENTER, border=0)
        v_sizer.Add(txt, proportion=0, flag=wx.CENTER, border=0)
        v_sizer.AddStretchSpacer()
        if platform.system() == "Darwin" and darkdetect.isDark():
            self.SetBackgroundColour(
                wx.Colour(32, 32, 32, alpha=wx.ALPHA_OPAQUE))
        else:
            self.SetBackgroundColour(
                wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
        self.SetSizer(v_sizer)
Ejemplo n.º 3
0
 def initWorking(self):
     global darkTheme, lightTheme
     self.working = None
     if isDark():
         self.setTheme(darkTheme)
     else:
         self.setTheme(lightTheme)
Ejemplo n.º 4
0
    def initUI(self):
        global darkTheme, lightTheme
        if isDark():
            apply_stylesheet(self.app, darkTheme)
        else:
            apply_stylesheet(self.app, lightTheme)

        self.lab = QLabel(text="", parent=self.win)
        self.lab.adjustSize(
        )  # It is a kind of better to do this to avoid bugs.

        self.wid = QWidget()

        vlayout = QVBoxLayout()
        self.win.setLayout(vlayout)
        vlayout.addWidget(self.lab)
        vlayout.addWidget(self.wid)

        # Making a widget to store buttons.
        layout = QGridLayout()
        self.wid.setLayout(layout)

        self.buttons = []

        for i in range(3):
            self.buttons.append([])
            for j in range(3):
                self.buttons[i].append(QPushButton())
                self.buttons[i][j].clicked.connect(
                    lambda _, i=i, j=j: self.onPress(i, j))
                layout.addWidget(self.buttons[i][j], i, j)
Ejemplo n.º 5
0
    def __init__(self, queue=List[str]):
        super().__init__(None, title="Data extraction...", size=(500, 100))
        self._q = queue.copy()
        self._now = 0
        self.progress = wx.Gauge(self, range=len(self._q) * 2, size=(350, -1))
        self.percent = wx.StaticText(self,
                                     id=wx.ID_ANY,
                                     label="0%",
                                     style=wx.ALIGN_RIGHT)
        self.percent.SetForegroundColour((96, 96, 96))
        self.percent.SetFont(
            wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_LIGHT))

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddStretchSpacer()
        sizer.Add(self.progress, 0, wx.EXPAND)
        sizer.AddStretchSpacer()
        sizer.Add(self.percent, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        sizer.AddStretchSpacer()
        if platform.system() == "Darwin" and darkdetect.isDark():
            self.SetBackgroundColour(
                wx.Colour(32, 32, 32, alpha=wx.ALPHA_OPAQUE))
        else:
            self.SetBackgroundColour(
                wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
        self.SetSizer(sizer)

        pub.subscribe(self.onProgress, "update")
Ejemplo n.º 6
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(False)

    # Create the icon
    if darkdetect.isDark():
        icon_image = "icon-light.png"
    else:
        icon_image = "icon-dark.png"
    icon = QIcon(icon_image)

    # Create the tray
    tray = QSystemTrayIcon()
    tray.setIcon(icon)
    tray.setVisible(True)

    # Create the menu
    menu = QMenu()
    action = QAction("A menu item")
    menu.addAction(action)

    # Add a Quit option to the menu.
    quit = QAction("Quit")
    quit.triggered.connect(app.quit)
    menu.addAction(quit)

    # Add the menu to the tray
    tray.setContextMenu(menu)
    sys.exit(app.exec_())
Ejemplo n.º 7
0
def getThemeGUI():
    if (platform.system() == "Darwin"):  #on mac
        if (darkdetect.isDark()):  #darkMode on
            return 'Black'
        else:
            return 'LightGray1'
    else:  #not on mac
        return 'Black'
Ejemplo n.º 8
0
    def macos_dark_mode(self) -> bool:
        if not getattr(sys, "frozen", False):
            return False
        if not isMac:
            return False
        import darkdetect  # pylint: disable=import-error

        return darkdetect.isDark() is True
Ejemplo n.º 9
0
    def macos_dark_mode(self) -> bool:
        if not getattr(sys, "frozen", False):
            return False
        if not isMac:
            return False
        if qtminor < 13:
            return False
        if self._macos_dark_mode_cached is None:
            import darkdetect  # pylint: disable=import-error

            # cache the value, as the interface gets messed up
            # if the value changes after starting Anki
            self._macos_dark_mode_cached = darkdetect.isDark() is True
        return self._macos_dark_mode_cached
Ejemplo n.º 10
0
def is_dark_mode() -> bool:
    if sys.platform.startswith("win"):
        from prettyqt import core

        path = (
            "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
            "Themes\\Personalize")
        settings = core.Settings(path, core.Settings.Format.NativeFormat)
        return settings.value("AppsUseLightTheme") == 0
    elif sys.platform == "darwin":
        import darkdetect

        return darkdetect.isDark()
    else:
        return False
Ejemplo n.º 11
0
def is_system_dark_theme():
    if is_macos():
        return darkdetect.isDark()

    if is_windows():
        k = winreg.OpenKey(
            winreg.HKEY_CURRENT_USER,
            'Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize'
        )
        try:
            return winreg.QueryValueEx(k, 'AppsUseLightTheme')[0] == 0
        except Exception:
            pass

    return False
Ejemplo n.º 12
0
    def initMenubar(self):
        global darkTheme, lightTheme
        if isDark():
            self.setTheme(darkTheme)
        else:
            self.setTheme(lightTheme)

        self.menubar = QMenuBar()
        self.themeMenu = QMenu("Theme Menu")

        self.lightThemeAction = QAction("Light Theme")
        self.lightThemeAction.triggered.connect(lambda : self.setTheme(lightTheme))
        self.themeMenu.addAction(self.lightThemeAction)

        self.darkThemeAction = QAction("Dark Theme")
        self.darkThemeAction.triggered.connect(lambda : self.setTheme(darkTheme))
        self.themeMenu.addAction(self.darkThemeAction)

        self.menubar.addMenu(self.themeMenu)
        self.mainWindow.setMenuBar(self.menubar)
Ejemplo n.º 13
0
def toggleTodoistTheme():

    with open("/usr/local/bin/darkmode/todoistCredentials.json", 'r') as f:
        payload = json.load(f)["payload"]

    r = requests.post("https://todoist.com/oauth/access_token", data=payload)

    if r.status_code != 200:
        print("Error getting access token from todoist oauth server")
        quit()

    todoistToken = r.json()["access_token"]
    api = todoist.TodoistAPI(todoistToken)

    TODOIST_LIGHT_THEME = 0
    TODOIST_DARK_THEME = 11

    api.user.update(theme=TODOIST_LIGHT_THEME if darkdetect.isDark(
    ) else TODOIST_DARK_THEME)

    api.commit()
Ejemplo n.º 14
0
from colorama import init, Fore, Back, Style
from datetime import datetime
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from webhook import DiscordWebhook, DiscordEmbed
from chromedriver_py import binary_path as driver_path
import json, platform, darkdetect, random, settings, threading
if platform.system == "Windows":
    init(convert=True)
    normal_color = Fore.WHITE
else:
    init()
    normal_color = Fore.WHITE if darkdetect.isDark() else Fore.BLACK
print(normal_color + "Welcome To Bird Bot")


class BirdLogger:
    def ts(self):
        return str(datetime.now())[:-7]

    def normal(self, task_id, msg):
        print(normal_color +
              "[{}][TASK {}] {}".format(self.ts(), task_id, msg))

    def alt(self, task_id, msg):
        print(Fore.MAGENTA +
              "[{}][TASK {}] {}".format(self.ts(), task_id, msg))

    def error(self, task_id, msg):
        print(Fore.RED + "[{}][TASK {}] {}".format(self.ts(), task_id, msg))
Ejemplo n.º 15
0
def is_dark():
    return darkdetect.isDark()
import tempfile
from botocore.exceptions import ClientError
import sys
from PyQt5 import QtWidgets, QtCore
from src.gui_connector_utils import buttons_connector
from gui.gui import Ui_main_window
from gui.error_display_functions import error, access_error
import darkdetect
from src.shared_utils import gui_initializer, dark_mode

with tempfile.TemporaryDirectory() as tmp_dir_name:
    try:
        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QWidget()
        ui = Ui_main_window()
        gui_initializer(ui, main_window, tmp_dir_name)

        #If darkmode make use the dark logo
        if darkdetect.isDark():
            dark_mode(ui)
        main_window.show()
        buttons_connector(ui)
    except ClientError as e:
        access_error(str(e))
    except Exception as e:
        error(str(e))
    sys.exit(app.exec_())
Ejemplo n.º 17
0
def is_darkmode(): return darkdetect.isDark() if is_macos() else False

#https://stackoverflow.com/a/11868398/11584108
def foreground_from_background(hex_str):
Ejemplo n.º 18
0
def main():
    # Arguments
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-l',
        '--logtofile',
        action='store_true',
        help=
        'enable logging in the file easyDiffraction.log in the system directory tmp instead of the terminal'
    )
    parser.add_argument(
        '-t',
        '--testmode',
        action='store_true',
        help=
        'run the application in test mode: run the tutorial, record a video and exit the application'
    )
    args = parser.parse_args()
    if args.logtofile:
        import easyApp.Logging

    # Paths
    app_name = CONFIG['tool']['poetry']['name']
    current_path = os.path.dirname(sys.argv[0])
    package_path = os.path.join(current_path, f'{app_name}App')
    if not os.path.exists(package_path):
        package_path = current_path

    main_qml_path = QUrl.fromLocalFile(
        os.path.join(package_path, 'Gui', 'main.qml'))
    gui_path = str(QUrl.fromLocalFile(package_path).toString())
    app_icon_path = os.path.join(package_path, 'Gui', 'Resources', 'Logo',
                                 'App.png')
    easyApp_path = os.path.join(easyApp2.__path__[0], '..')

    home_path = pathlib.Path.home()
    settings_path = str(home_path.joinpath(f'.{app_name}', 'settings.ini'))

    languages = CONFIG['ci']['app']['translations']['languages']
    translations_dir = CONFIG['ci']['app']['translations']['dir']
    translations_path = os.path.join(package_path,
                                     *translations_dir.split('/'))

    # QtWebEngine
    QtWebEngine.initialize()

    # Application
    app = App(sys.argv)
    app.setApplicationName(CONFIG['tool']['poetry']['name'])
    app.setApplicationVersion(CONFIG['tool']['poetry']['version'])
    app.setOrganizationName(CONFIG['tool']['poetry']['name'])
    app.setOrganizationDomain(CONFIG['tool']['poetry']['name'])
    app.setWindowIcon(QIcon(app_icon_path))

    app.setWindowIcon(
        QIcon(os.path.join(package_path, 'Gui', 'Resources', 'Logo',
                           'App.png')))
    # QML application engine
    engine = QQmlApplicationEngine()

    # Python objects to be exposed to QML
    py_qml_proxy_obj = PyQmlProxy()
    translator = Translator(app, engine, translations_path, languages)

    # Expose the Python objects to QML
    engine.rootContext().setContextProperty('_pyQmlProxyObj', py_qml_proxy_obj)
    engine.rootContext().setContextProperty('_settingsPath', settings_path)
    engine.rootContext().setContextProperty('_translator', translator)
    engine.rootContext().setContextProperty('_projectConfig', CONFIG)
    engine.rootContext().setContextProperty('_isTestMode', args.testmode)
    engine.rootContext().setContextProperty('_isSystemThemeDark',
                                            darkdetect.isDark())

    # Register types to be instantiated in QML
    qmlRegisterType(Updater, 'easyApp.Logic.Maintenance', 1, 0, 'Updater')

    # Add paths to search for installed modules
    engine.addImportPath(easyApp_path)
    engine.addImportPath(gui_path)

    # Load the root QML file
    engine.load(main_qml_path)

    # Customize app window titlebar
    if platform.system() == "Darwin":
        import ctypes, objc, Cocoa

        # Root application window
        root_obj = engine.rootObjects()
        if not root_obj:
            sys.exit(-1)
        root_window = root_obj[0]

        ptr = int(root_window.winId())
        view = objc.objc_object(c_void_p=ctypes.c_void_p(ptr))
        window = view._.window

        window.setStyleMask_(window.styleMask()
                             | Cocoa.NSFullSizeContentViewWindowMask)
        window.setTitlebarAppearsTransparent_(True)
        window.setTitleVisibility_(Cocoa.NSWindowTitleHidden)

    # Event loop
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
Ejemplo n.º 19
0
def toggleHyperTheme():
    setLightCmd = "sed -i '' -e '/hyper-one-light/ s://::g' $(echo $HOME)/.hyper.js"
    setDarkCmd = "sed -i '' -e '/hyper-one-light/ s:^://:g' $(echo $HOME)/.hyper.js"

    os.system(setLightCmd if darkdetect.isDark() else setDarkCmd)
Ejemplo n.º 20
0
    def __init__(self, parent, status_queue):
        """
        Initialize preferences window.

        It allows to:

        * enable or disable process discovery analysis
        * select the number of runs after which event log is generated
        * select analysis type (either decision points or most frequent routine)

        :param status_queue: queue to send messages to main GUI
        """
        super(Preferences, self).__init__(
            parent,
            flags=Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint
            | Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint)

        self.status_queue = status_queue
        self.setWindowTitle(" ")
        if WINDOWS:
            self.resize(360, 320)

        if WINDOWS:
            monospaceFont = 'Lucida Console'
            fontSize = 10
        elif MAC:
            monospaceFont = 'Monaco'
            fontSize = 13
        else:
            monospaceFont = 'monospace'
            fontSize = 13
        font = QFont(monospaceFont, fontSize, QFont.Normal)

        self.decisionGroupBox = QGroupBox("Analysis type")

        self.process_discovery_cb = QCheckBox(
            "Enable Process Discovery \nanalysis on event log")
        self.process_discovery_cb.setToolTip(
            "If enabled, process discovery analysis is performed automatically\n"
            "after selecting event log file, otherwise only event log is generated"
        )
        self.process_discovery_cb.tag = "process_discovery_cb"
        self.process_discovery_cb.stateChanged.connect(self.handle_cb)
        perform_process_discovery = utils.config.MyConfig.get_instance(
        ).perform_process_discovery
        self.process_discovery_cb.setChecked(perform_process_discovery)
        self.decisionGroupBox.setEnabled(perform_process_discovery)

        self.mfr = QRadioButton("Most frequent routine")
        self.mfr.clicked.connect(self.handle_radio)
        self.mfr.setChecked(utils.config.MyConfig.get_instance().
                            enable_most_frequent_routine_analysis)
        self.mfr.setToolTip(
            "Create SW Robot based on most frequent routine in the event log")

        self.decision = QRadioButton("Decision points")
        self.decision.clicked.connect(self.handle_radio)
        self.decision.setChecked(utils.config.MyConfig.get_instance().
                                 enable_decision_point_analysis)
        self.decision.setToolTip("Create SW Robot based on user decisions")

        self.decisionRPA = QRadioButton("Decision points in UiPath")
        self.decisionRPA.clicked.connect(self.handle_radio)
        self.decisionRPA.setChecked(utils.config.MyConfig.get_instance().
                                    enable_decision_point_RPA_analysis)
        self.decisionRPA.setToolTip(
            "Create SW Robot that asks for user decisions in UiPath script")

        slider_minimum = 1 if utils.config.MyConfig.get_instance(
        ).enable_most_frequent_routine_analysis else 2
        slider_maximum = 30

        self.lcd = QLCDNumber(self)
        self.lcd.setMinimumHeight(45)

        self.sld = QSlider(Qt.Horizontal, self)
        self.sld.setMinimum(slider_minimum)
        self.sld.setMaximum(slider_maximum)
        self.sld.setValue(
            utils.config.MyConfig.get_instance().totalNumberOfRunGuiXes)
        self.sld.valueChanged.connect(self.handle_slider)

        label_minimum = QLabel(str(1), alignment=Qt.AlignLeft, font=font)
        label_maximum = QLabel(str(slider_maximum),
                               alignment=Qt.AlignRight,
                               font=font)

        self.slider_label = QLabel(
            "Number of runs after which \nevent is generated:")
        self.slider_label.setToolTip(
            "When the selected number of runs is reached, all CSV logs collected are merged into one \nand a XES file "
            "is automatically generated, to be used for process mining techniques"
        )
        self.handle_slider()

        confirmButton = QPushButton("OK")
        confirmButton.setCheckable(True)
        confirmButton.setChecked(False)
        confirmButton.clicked.connect(self.handleButton)
        if darkdetect.isDark():
            confirmButton.setStyleSheet(
                'QPushButton {background-color: #656565;}')

        processDiscoveryGroupBox = QGroupBox("Process Discovery")
        vbox = QVBoxLayout()
        vbox.addWidget(self.process_discovery_cb)
        processDiscoveryGroupBox.setLayout(vbox)

        vbox = QVBoxLayout()
        vbox.addWidget(self.mfr)
        vbox.addWidget(self.decision)
        # vbox.addWidget(self.decisionRPA)
        self.decisionGroupBox.setLayout(vbox)

        xesGroupBox = QGroupBox()
        vbox = QVBoxLayout()
        vbox.addWidget(self.slider_label)
        vbox.addWidget(self.lcd)
        vbox.addSpacing(10)
        vbox.addWidget(self.sld)
        hbox = QHBoxLayout()
        hbox.addWidget(label_minimum, Qt.AlignLeft)
        hbox.addWidget(label_maximum, Qt.AlignRight)
        vbox.addLayout(hbox)
        xesGroupBox.setLayout(vbox)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(processDiscoveryGroupBox)
        mainLayout.addWidget(self.decisionGroupBox)
        mainLayout.addWidget(xesGroupBox)
        mainLayout.addWidget(confirmButton)

        wid = QWidget(self)
        self.setCentralWidget(wid)
        wid.setLayout(mainLayout)
        wid.setGeometry(300, 300, 250, 150)
        wid.show()
Ejemplo n.º 21
0
    def __init__(self, df: pandas.DataFrame):
        """

        :param df: low level dataframe of decided trace or most frequent routine
        """
        
        # flags = Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint
        super(ChoicesDialog, self).__init__()
        self.setWindowTitle("Choices")

        # self.setMaximumWidth(1000)
        # self.setMaximumHeight(600)
        if WINDOWS:
            self.setFixedWidth(1000)
        else:
            self.setFixedWidth(750)

        self.df = df

        # remove empty clipboard items
        for row_index, row in self.df.iterrows():
            e = row['concept:name']
            if (e in ['cut', 'copy', 'paste']) and utils.removeWhitespaces(row['clipboard_content']) == '':
                self.df = self.df.drop(row_index)

        # take selected event names
        mask1 = self.df['concept:name'].isin(
            ['changeField',
             'editCell', 'editCellSheet', 'editRange',
             'created', 'moved', 'Unmount', 'hotkey', 'copy']
        )
        # exclude paste in browser, take only paste in OS, do not consider cut or copy
        mask2 = ((self.df['concept:name'] == 'paste') & (self.df['category'] != 'Browser'))
        self.filtered_df = self.df[mask1 | mask2]

        if not self.filtered_df.empty:

            buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
            buttonBox.accepted.connect(self.handleReturn)
            if darkdetect.isDark():
                buttonBox.setStyleSheet('QPushButton {background-color: #656565;}')

            formGroupBox = QGroupBox()
            self.layout = QFormLayout()
            self.addRows()
            formGroupBox.setLayout(self.layout)

            scroll = QScrollArea()
            scroll.setWidget(formGroupBox)
            scroll.setMaximumHeight(600)
            scroll.setMaximumWidth(1000)

            mainLayout = QVBoxLayout()
            mainLayout.addWidget(QLabel("Change input variables before generating RPA script"))
            mainLayout.addWidget(scroll)
            mainLayout.addWidget(buttonBox)

            self.setLayout(mainLayout)

        else:
            buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
            buttonBox.accepted.connect(self.accept)
            layout = QVBoxLayout(self)
            layout.addWidget(QLabel("Most frequent trace does not contain editable fields.\n"
                                    "Press OK to generate RPA script."))
            layout.addWidget(buttonBox)
            self.setLayout(layout)