Exemple #1
0
    def _fillControls(self):
        s = SettingsManager()
        iStartPos, _ = s.MainWndStartupPos
        if iStartPos == wx.ALIGN_NOT:
            self.optStartType[1].SetValue(True)
            self.optDefPos[4].SetValue(True)
        else:
            self.optStartType[0].SetValue(True)
            if iStartPos == (wx.ALIGN_CENTER_HORIZONTAL
                             | wx.ALIGN_CENTER_VERTICAL):
                self.optDefPos[4].SetValue(True)
            else:
                iX = 0
                if (iStartPos & wx.RIGHT) == wx.RIGHT:
                    iX = 2
                elif (iStartPos & wx.LEFT) == wx.LEFT:
                    iX = 0
                else:
                    iX = 1
                iY = 0
                if (iStartPos & wx.BOTTOM) == wx.BOTTOM:
                    iY = 6
                elif (iStartPos & wx.TOP) == wx.TOP:
                    iY = 0
                else:
                    iY = 3
                self.optDefPos[iX + iY].SetValue(True)
        self.OnStartupPosTypeChanged(None)

        self.chkSingleInstance.SetValue(s.MultipleInstancesAllowed is False)
        self.chkCompFile.SetValue(s.CompressSettingsFile)

        self.btnApply.Disable()
Exemple #2
0
    def OnInit(self):
        print('Running wxPython ' + wx.version())
        # Set Current directory to the one containing this file
        os.chdir(os.path.dirname(os.path.abspath(__file__)))

        self.SetAppName('SettingsManager')

        s = SettingsManager()
        s.ReadSettings()
        self._snglInstChecker = wx.SingleInstanceChecker()
        self._snglInstChecker.CreateDefault()
        if self._snglInstChecker.IsAnotherRunning(
        ) and not s.MultipleInstancesAllowed:
            wx.MessageBox(
                'Another instance of this application is already running!',
                'Multiple instances not allowed',
                wx.OK | wx.ICON_EXCLAMATION | wx.CENTER)
            return False

        # Create the main window
        frm = MainFrame()
        self.SetTopWindow(frm)

        frm.Show()
        return True
Exemple #3
0
    def _applySettings(self):
        s = SettingsManager()
        iIndex = wx.NOT_FOUND
        if self.optStartType[0].GetValue() is True:
            for i, o in enumerate(self.optDefPos):
                if o.GetValue() is True:
                    iIndex = i
                    break
        iStartPos = wx.ALIGN_NOT
        if iIndex > wx.NOT_FOUND:
            iH = 0
            if iIndex in [0, 3, 6]:
                iH = wx.LEFT
            elif iIndex in [1, 4, 7]:
                iH = wx.CENTER
            else:
                iH = wx.RIGHT
            iV = 0
            if (iIndex > -1) and (iIndex < 3):
                iV = wx.TOP
            elif (iIndex > 2) and (iIndex < 6):
                iV = wx.CENTER
            else:
                iV = wx.BOTTOM
            if (iH == wx.CENTER) and (iV == wx.CENTER):
                iStartPos = (wx.ALIGN_CENTER_HORIZONTAL
                             | wx.ALIGN_CENTER_VERTICAL)
            else:
                iStartPos = iH | iV
        s.MainWndStartupPos = iStartPos

        s.MultipleInstancesAllowed = self.chkSingleInstance.IsChecked(
        ) is False
        s.CompressSettingsFile = self.chkCompFile.IsChecked()
        self.btnApply.Disable()
Exemple #4
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.grass_result: Grasser.GrassResult
        self.settings_manager = SettingsManager()
        self.settings_manager.setup_settings(self)
        self.grasser = GoogleGrasser(
            config_file_name=self.config_file_name,
            service_url=self.google_translate_service_url,
            no_english=self.random_grass_no_english)
        self.config_manager = ConfigManager(self.config_file_name)

        self.change_style(self.application_style)

        self.ui = Ui_application()
        self.ui.setupUi(self)
        self.ui.select_config.addItems(["随机"] +
                                       self.config_manager.return_all_config())
        self.ui.select_google_translate_url.addItems(constants.SERVICE_URLS)
        self.ui.select_application_style.addItems(QStyleFactory.keys())

        self.GrassingThread = QThread(self)
        self.OnClick = OnClick(self)
        self.OnClick.moveToThread(self.GrassingThread)

        self.ui.start_grass.clicked.connect(self.on_start_grass_click)
        self.ui.open_file.clicked.connect(self.on_open_file_click)
        self.ui.copy_result.clicked.connect(self.on_copy_result_click)
        self.ui.save_this_grass_as_config.clicked.connect(
            self.on_save_this_grass_as_config_click)
        self.ui.save_result.clicked.connect(self.on_save_grass_result_click)

        self.OnClick.set_grass_result.connect(self.set_grass_result)
        self.OnClick.warning.connect(self.warning_dialog)
        self.OnClick.quit.connect(self.quit_onclick_thread)
        self.ui.select_google_translate_url.currentTextChanged.connect(
            self.on_select_google_translate_url_current_index_changed)
        self.GrassingThread.started.connect(
            lambda: self.OnClick.on_start_grass_click(
                self.grasser, self.ui.original_text_edit.toPlainText(),
                self.ui.grass_frequency.value(),
                self.ui.select_config.currentText()))
        self.ui.second_setting_option_button_group.buttonClicked.connect(
            self.on_second_setting_option_click)
        self.ui.set_config_file_name.returnPressed.connect(
            self.on_set_config_file_name_return_pressed)
        self.ui.select_application_style.currentTextChanged.connect(
            self.select_application_style_current_index_changed)

        self.ui.select_google_translate_url.setCurrentIndex(
            constants.SERVICE_URLS.index(self.google_translate_service_url))
        self.ui.select_application_style.setCurrentIndex(
            QStyleFactory.keys().index(self.application_style))

        if self.random_grass_no_english:
            self.ui.radio_first_setting_option.setChecked(True)
        else:
            self.ui.radio_second_setting_option.setChecked(True)
Exemple #5
0
    def __init__(self):
        self.player = None  #New Player
        self.app = QApplication([])
        dir_ = QDir("fonts")  #Set working directory
        #Set application details and icon
        self.app.setApplicationName("Chess Player")
        self.app.setApplicationDisplayName("Chess Player")
        self.app.setWindowIcon(QIcon("icons/chess_icon.ico"))

        #Get SettingsManager Instance
        self.settingsManager = SettingsManager()
Exemple #6
0
    def _onWindowResized(self, evt):
        if not self.IsShown():
            return
        s = SettingsManager()
        if self.IsMaximized():
            s.MainWndStartupPos = wx.DefaultPosition
            s.MainWndStartupSize = wx.DefaultSize
        else:
            s.MainWndStartupRect = self.GetRect()

        evt.Skip()
    def __init__(self, iface):
        # initialise plugin directory
        self.plugin_dir = os.path.dirname(__file__)

        # initialize locale
        locale = QtCore.QSettings().value("locale/userLocale")[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'essTools_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QtCore.QTranslator()
            self.translator.load(locale_path)

            if QtCore.qVersion() > '4.3.3':
                QtCore.QCoreApplication.installTranslator(self.translator)

        # Save reference to the QGIS interface
        self.iface = iface
        self.toolbar = self.iface.addToolBar(u"Space Syntax Toolkit")
        self.menu = self.tr(u"&Space Syntax Toolkit")
        self.actions = []

        # Create toolkit components
        self.settings = SettingsManager(self.iface)
        self.settings_action = None
        self.project = ProjectManager(self.iface, self.settings)
        self.project_action = None
        self.about = AboutDialog()
        self.about_action = None

        # for remote debugging
        if has_pydevd and is_debug:
            pydevd.settrace('localhost',
                            port=53100,
                            stdoutToServer=True,
                            stderrToServer=True,
                            suspend=False)

        ###########
        ###########
        # initialise the different modules
        self.analysis = AnalysisTool.AnalysisTool(self.iface, self.settings,
                                                  self.project)
        self.explorer = ExplorerTool.ExplorerTool(self.iface, self.settings,
                                                  self.project)
        self.gate_transformer = TransformerAnalysis.GateTransformer(self.iface)
        self.rcl_cleaner = RoadNetworkCleanerTool.RoadNetworkCleaner(
            self.iface)
        self.catchment_tool = CatchmentAnalyser.CatchmentTool(self.iface)
        self.udi_tool = UrbanDataInputTool.UrbanDataInputTool(self.iface)
    def __init__(self, iface):
        # initialise plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        locale = QtCore.QSettings().value("locale/userLocale")[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n', 'essTools_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QtCore.QTranslator()
            self.translator.load(locale_path)

            if QtCore.qVersion() > '4.3.3':
                QtCore.QCoreApplication.installTranslator(self.translator)

        # Save reference to the QGIS interface
        self.iface = iface
        self.esst_toolbar = self.iface.addToolBar(u"Space Syntax Toolkit")

        # initialise base modules and interface actions
        self.settings = SettingsManager(self.iface)
        self.settings_action = None
        self.project = ProjectManager(self.iface, self.settings)
        self.project_action = None

        # initialise the tool modules and interface actions
        self.analysis = AnalysisTool.AnalysisTool(self.iface, self.settings, self.project)
        self.analysis_action = None
        self.explorer = ExplorerTool.ExplorerTool(self.iface, self.settings, self.project)
        self.explorer_action = None
        # Create other dialogs
        self.about = AboutDialog()
        about_msg = (
        'The "Space Syntax Toolkit" was originally developed at the Space Syntax Laboratory, '
        'the Bartlett School of Architecture, University College London (UCL).\n\n'
        'Author: Jorge Gil\n\n'
        'Contributors: Tasos Varoudis\n\n'
        'Contact: [email protected]\n\n'
        'Released under GNU Licence version 3')
        self.about.messageText.setText(about_msg)
        self.about.logoLabel.setPixmap(QPixmap(os.path.dirname(__file__) + '/icons/ucl.png'))
        self.about.logoLabel.setScaledContents(True)
        self.about_action = None
        self.help_action = None

        # initialise default events
        #self.project.loadSettings()

        if has_pydevd and is_debug:
            pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True, suspend=False)
    def __init__(self, iface):
        # initialise plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        locale = QtCore.QSettings().value("locale/userLocale")[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'essTools_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QtCore.QTranslator()
            self.translator.load(locale_path)

            if QtCore.qVersion() > '4.3.3':
                QtCore.QCoreApplication.installTranslator(self.translator)

        # Save reference to the QGIS interface
        self.iface = iface
        self.esst_toolbar = self.iface.addToolBar(u"Space Syntax Toolkit")

        # initialise base modules and interface actions
        self.settings = SettingsManager(self.iface)
        self.settings_action = None
        self.project = ProjectManager(self.iface, self.settings)
        self.project_action = None

        # initialise the tool modules and interface actions
        self.analysis = AnalysisTool.AnalysisTool(self.iface, self.settings,
                                                  self.project)
        self.analysis_action = None
        self.explorer = ExplorerTool.ExplorerTool(self.iface, self.settings,
                                                  self.project)
        self.explorer_action = None
        # Create other dialogs
        self.about = AboutDialog()
        self.about_action = None
        self.help_action = None

        # initialise default events
        #self.project.loadSettings()

        if has_pydevd and is_debug:
            pydevd.settrace('localhost',
                            port=53100,
                            stdoutToServer=True,
                            stderrToServer=True)
Exemple #10
0
    def __init__(self):
        wx.Frame.__init__(self, None, title=wx.GetApp().GetAppName())
        self.SetIcon(wx.Icon('../../common/wxwin.ico'))

        self._createControls()

        # Minimum client size of the main window
        self.SetMinClientSize(wx.Size(400, 300))

        s = SettingsManager()
        mode, pos = s.MainWndStartupPos
        sz = s.MainWndStartupSize
        if mode == wx.ALIGN_NOT:
            if sz == wx.DefaultSize:
                if pos == wx.DefaultPosition:
                    self.Maximize()
                else:
                    self.CenterOnScreen()
            else:
                self.Move(pos)
                self.SetSize(sz)
        else:
            iWScr, iHScr = wx.GetDisplaySize()
            if sz == wx.DefaultSize:
                sz = self.GetSize()
            pt = wx.DefaultPosition
            if (mode & wx.LEFT) == wx.LEFT:
                pt.x = 0
            elif (mode & wx.RIGHT) == wx.RIGHT:
                pt.x = iWScr - sz.GetWidth()
            else:
                pt.x = (iWScr - sz.GetWidth()) / 2
            if (mode & wx.TOP) == wx.TOP:
                pt.y = 0
            elif (mode & wx.BOTTOM) == wx.BOTTOM:
                pt.y = iHScr - sz.GetHeight()
            else:
                pt.y = (iHScr - sz.GetHeight()) / 2
            self.Move(pt)
            self.SetSize(sz)

        self._connectControls()
Exemple #11
0
 def OnExit(self):
     s = SettingsManager()
     if s.Modified is True:
         s.SaveSettings()
     return wx.App.OnExit(self)
Exemple #12
0
    def _onWindowMoved(self, evt):
        if not self.IsShown():
            return
        SettingsManager().MainWndStartupRect = self.GetRect()

        evt.Skip()
Exemple #13
0
import os
import cv2 as cv
import sysv_ipc as ipc
import time
from subprocess import call
from threading import Thread
from InputManager import InputManager
from SettingsManager import SettingsManager
from LedDriver import LedDriver
from StateMachine import StateMachine
from SACOnScreenDisplay.OSD import OSD
from picamera.array import PiRGBArray
from picamera import PiCamera

settingsManager = SettingsManager()
inputManager = InputManager(5, 6, 13)
ledDriver = LedDriver(17, 27, 22)
stateMachine = StateMachine(settingsManager, ledDriver)
osd = OSD(inputManager, settingsManager)

# Target screen is 12", 1024x768 or 768x1024 in portrait mode
screenWidth = 768
screenHeight = 1024
# Sensor size is 80x60
sensorWidth = 80
sensorHeight = 60
# Lepton offset in degC
corrVal = 0
maxVal = 0
feverThresh = 35.4
Exemple #14
0
def main(argc, argv):

    # The default profile settings for the application
    default_settings = {
        'subreddits': {},
        'profile_name': 'Default',
        'center_image': False,
        'mirror_image': False,
        'fill_voidspace': False,
        'fill_behavior': {
            'solid_fill': False,
            'random_fill': False,
            'smart_fill': False
        },
        'fill_color': '#000000',
        'max_scale_factor': 1.7,
        'chaos_tolerance': 100,
        'images_to_download': 50,
        'download_interval': 86400
    }

    # Create a JsonHandler object to handle importing and exporting profile data
    json_handler = JsonHandler(filename=DATABASE_FILENAME,
                               json_data=default_settings)

    # Create a SettingsManager to handle the GUI elements of the application (collecting user settings)
    settings_manager = SettingsManager(settings_dict=json_handler.json_data,
                                       database=json_handler)

    # The SettingsManager works best in Windows when it's run in its own thread
    # NOTE:	After some changes this is no longer the case. Do not revise this code segment
    #	until after threaded functionality is removed from SettingsManager
    if sys.platform in supported_platforms:
        if sys.platform == 'darwin':
            settings_manager.run()
        elif sys.platform == 'win32':
            # settings_manager.start()
            # settings_manager.join()
            settings_manager.run()
        else:
            print('Unknown platform. Exiting...')
            sys.exit(1)

    # If the settings_manager exited while launch set to True (if the user pressed 'launch' to exit the menu)
    if settings_manager.launch:
        # Create a new RedditInterface to handle requesting posts
        reddit_interface = RedditInterface(
            settings_dict=json_handler.json_data)
        reddit_interface.get_images()

        # Create a new ImageHandler
        image_folder_location = downloaded_image_folder_location
        image_handler = ImageHandler(image_folder_location,
                                     json_handler.json_data)

        # Do not use any images that fail the resolution check
        image_handler.flush_images_by_resolution()

        # Resize images and perform other operations based on user settings
        image_handler.resize_images()

    # Create a timer object and set it on a loop
    """