コード例 #1
0
    def __init__(self,
                 parent: Window,
                 displayText: str,
                 valueChangedCallback: Callable,
                 minValue: int = DEFAULT_MIN_VALUE,
                 maxValue: int = DEFAULT_MAX_VALUE):
        """

        Args:
            parent          The parent window
            displayText:    The text to display as the static box title
            valueChangedCallback:  The method to call when the value changes;  The method should expect the
                                   first parameter to be an object of type SpinnerValues
            minValue:       The minimum value for the width/height
            maxValue:       The maximum value for the width/height

        """
        self.logger: Logger = getLogger(__name__)
        self.__callback: Callable = valueChangedCallback

        box: StaticBox = StaticBox(parent, ID_ANY, displayText)

        super().__init__(box, HORIZONTAL)

        self._wxValue0SpinnerId: int = wxNewIdRef()
        self._wxValue1SpinnerId: int = wxNewIdRef()

        self._scValue0: SpinCtrl = SpinCtrl(parent, self._wxValue0SpinnerId,
                                            "",
                                            (SPINNER_WIDTH, SPINNER_HEIGHT))
        self._scValue1: SpinCtrl = SpinCtrl(parent, self._wxValue1SpinnerId,
                                            "",
                                            (SPINNER_WIDTH, SPINNER_HEIGHT))

        self.Add(self._scValue0, 0, ALL, DualSpinnerContainer.HORIZONTAL_GAP)
        self.Add(self._scValue1, 0, ALL, DualSpinnerContainer.HORIZONTAL_GAP)

        self._scValue0.SetRange(minValue, maxValue)
        self._scValue1.SetRange(minValue, maxValue)

        parent.Bind(EVT_SPINCTRL,
                    self.__onSpinnerValueChanged,
                    id=self._wxValue0SpinnerId)
        parent.Bind(EVT_SPINCTRL,
                    self.__onSpinnerValueChanged,
                    id=self._wxValue1SpinnerId)

        self._spinnerValues: SpinnerValues = SpinnerValues(minValue, minValue)
コード例 #2
0
ファイル: DlgAbout.py プロジェクト: hasii2011/gittodoistclone
    def __init__(self, parent: Window, wxID: int = wxNewIdRef()):

        super().__init__(parent,
                         wxID,
                         'About',
                         DefaultPosition,
                         size=Size(width=390, height=250))

        self._versionFont: Font = self.GetFont()

        self._versionFont.SetFamily(FONTFAMILY_DEFAULT)

        self._version: Version = Version()  # Get the singleton

        dlgButtonsContainer: Sizer = self._createDialogButtonsContainer()

        # Main sizer
        mainSizer: BoxSizer = BoxSizer(VERTICAL)
        dialogSizer: BoxSizer = self._createUpperDialog()

        mainSizer.Add(dialogSizer, 0, ALL | ALIGN_LEFT, 5)
        mainSizer.Add(dlgButtonsContainer, 0, ALL | ALIGN_CENTER, 5)

        # noinspection PyUnresolvedReferences
        self.SetAutoLayout(True)
        # noinspection PyUnresolvedReferences
        self.SetSizer(mainSizer)
        self.Center(BOTH)
        self.SetBackgroundColour(WHITE)

        self.Bind(EVT_BUTTON, self._onOk, id=ID_OK)
        self.Bind(EVT_CLOSE, self._onOk)
コード例 #3
0
    def __init__(self, parent, labelText: str, valueChangedCallback: Callable, textControlSize: Tuple = (315, -1)):
        """

        Args:
            parent:     The parent window

            labelText:  How to label the text input

            valueChangedCallback:  The method to call when the value changes;  The method should expect the
            first parameter to be a string argument that is the new value

            textControlSize:  A tuple of (width, height) for the text input
        """

        super().__init__(parent)

        self._textControlSize: Tuple = textControlSize
        self.SetSizerType('form')
        self._textId:  int = wxNewIdRef()

        self._callback: Callable = valueChangedCallback

        # noinspection PyUnusedLocal
        textLabel:   StaticText = StaticText(self, ID_ANY, labelText)
        textControl: TextCtrl   = TextCtrl(self, self._textId, "", size=self._textControlSize)
        # noinspection PyUnresolvedReferences
        textControl.SetSizerProps(expand=True, halign='right')

        self._textControl:  TextCtrl = textControl
        self._textValue:    str      = ''

        # noinspection PyUnresolvedReferences
        self.SetSizerProps(expand=True)
        parent.Bind(EVT_TEXT, self._onTextValueChanged, id=self._textId)
コード例 #4
0
ファイル: TextContainer.py プロジェクト: hasii2011/PyUt
    def __init__(self, parent: Window, labelText: str,
                 valueChangedCallback: Callable):
        """

        Args:
            parent:     The parent window
            labelText:  How to label the text input
            valueChangedCallback:  The method to call when the value changes;  The method should expect the
            first parameter to be a string argument that is the new value
        """

        super().__init__(HORIZONTAL)

        self._textId: int = wxNewIdRef()

        self._callback: Callable = valueChangedCallback

        textLabel: StaticText = StaticText(parent, ID_ANY, labelText)
        textControl: TextCtrl = TextCtrl(parent, self._textId)

        self.Add(textLabel, WX_SIZER_CHANGEABLE, ALL | ALIGN_CENTER_VERTICAL,
                 TextContainer.HORIZONTAL_GAP)
        self.Add(textControl, WX_SIZER_CHANGEABLE, ALL,
                 TextContainer.HORIZONTAL_GAP)

        self._textControl: TextCtrl = textControl
        self._textValue: str = ''

        parent.Bind(EVT_TEXT, self._onTextValueChanged, id=self._textId)
コード例 #5
0
    def __init__(self, parent: Window):

        super().__init__(parent=parent)

        self.__centerAppOnStartupId: int = wxNewIdRef()

        self._createControls()

        self._valuesChanged: bool = False
コード例 #6
0
    def _createControls(self):
        """
        Creates the panel's controls and stashes them as private instance variables
        """
        self._textId = wxNewIdRef()

        self._cacheOptionControl         = CheckBox(parent=self, label="Allow Todoist Cache Cleanup", id=ID_ANY)
        self._tasksInParentOption        = CheckBox(parent=self, label="Single Todoist Project",     id=ID_ANY)
        self._parentProjectNameContainer = TextContainer(parent=self, labelText='Todoist Project Name:',
                                                         valueChangedCallback=self.__onParentProjectNameChange)
コード例 #7
0
    def _createIssueSelection(self) -> StaticBoxSizer:

        issueWxID: int = wxNewIdRef()

        self._issueList: ListBox = ListBox(self,
                                           issueWxID,
                                           style=LB_MULTIPLE | LB_OWNERDRAW)

        # noinspection PyUnresolvedReferences
        self._issueList.Enable(False)
        sz = StaticBoxSizer(VERTICAL, self, "Repository Issues")
        sz.Add(self._issueList, BasePanel.PROPORTION_CHANGEABLE, EXPAND)

        return sz
コード例 #8
0
    def _createTodoTaskList(self) -> StaticBoxSizer:

        taskWxID: int = wxNewIdRef()

        self._taskList: ListBox = ListBox(self,
                                          taskWxID,
                                          style=LB_OWNERDRAW | LB_ALWAYS_SB)
        # noinspection PyUnresolvedReferences
        self._taskList.Enable(False)

        sz = StaticBoxSizer(VERTICAL, self, "Todoist Tasks")
        sz.Add(self._taskList, BasePanel.PROPORTION_CHANGEABLE, EXPAND)

        self._taskList.SetItems(['Empty'])
        return sz
コード例 #9
0
ファイル: PyutUtils.py プロジェクト: hasii2011/PyUt
    def assignID(numberOfIds: int) -> List[wxNewIdRef]:
        """
        Assign and return numberOfIds

        Sample use        : [Unique_Id1, Unique_Id2, Unique_Id3] = assignID(3)

        Args:
            numberOfIds: number of unique IDs to return

        Returns:  List of numbers which contain <numberOfIds> unique IDs
        """
        retList: List[wxNewIdRef] = []
        x: int = 0
        while x < numberOfIds:
            retList.append(wxNewIdRef())
            x += 1
        return retList
コード例 #10
0
    def _createMilestoneSelection(self) -> StaticBoxSizer:

        milestoneSelectionWxId: int = wxNewIdRef()

        self._milestoneList: ListBox = ListBox(self,
                                               milestoneSelectionWxId,
                                               style=LB_SINGLE | LB_OWNERDRAW)

        # noinspection PyUnresolvedReferences
        self._milestoneList.Enable(False)
        sz = StaticBoxSizer(VERTICAL, self, "Repository Milestone Titles")
        sz.Add(self._milestoneList, BasePanel.PROPORTION_CHANGEABLE, EXPAND)

        self.Bind(EVT_LISTBOX, self._onMilestoneSelected,
                  milestoneSelectionWxId)

        return sz
コード例 #11
0
    def _createTasksButton(self) -> BoxSizer:

        bSizer: BoxSizer = BoxSizer(HORIZONTAL)
        createTaskWxID: int = wxNewIdRef()

        self._createTaskButton: Button = Button(self,
                                                id=createTaskWxID,
                                                style=BU_LEFT,
                                                label='Create Tasks')

        # noinspection PyUnresolvedReferences
        self._createTaskButton.Disable()
        bSizer.Add(self._createTaskButton, BasePanel.PROPORTION_NOT_CHANGEABLE,
                   ALL, 1)

        self.Bind(EVT_BUTTON, self._onCreateTaskClicked, id=createTaskWxID)
        return bSizer
コード例 #12
0
    def __init__(self, parent: Window, wxID: int = wxNewIdRef()):

        super().__init__(parent,
                         wxID,
                         'Helpful Hints',
                         style=DEFAULT_DIALOG_STYLE)

        self.Center(BOTH)
        pane: SizedPanel = self.GetContentsPane()
        pane.SetSizerType('horizontal')
        self._createHTMLPanel(sizedPanel=pane)
        self.SetButtonSizer(self.CreateStdDialogButtonSizer(OK))

        self.Fit()
        self.SetMinSize(self.GetSize())

        self.Bind(EVT_BUTTON, self.__onCmdOk, id=ID_OK)
        self.Bind(EVT_CLOSE, self.__onCmdOk)
コード例 #13
0
    def _createRepositorySelection(self) -> StaticBoxSizer:

        repoSelectionWxId: int = wxNewIdRef()

        self._repositorySelection: ComboBox = ComboBox(self,
                                                       repoSelectionWxId,
                                                       style=CB_DROPDOWN
                                                       | CB_READONLY)

        sz = StaticBoxSizer(VERTICAL, self, "Repository List")
        sz.Add(self._repositorySelection, BasePanel.PROPORTION_NOT_CHANGEABLE,
               EXPAND)

        self.__populateRepositories()

        self.Bind(EVT_COMBOBOX,
                  self._onRepositorySelected,
                  id=repoSelectionWxId)

        return sz
コード例 #14
0
    def __init__(self, parent: Window, wxID: int = wxNewIdRef()):
        """

        Args:
            parent:   Parent window
            wxID:   A control ID if caller wants one
        """

        super().__init__(parent,
                         wxID,
                         'Configure',
                         style=CAPTION | CLOSE_BOX | DIALOG_EX_METAL)

        self.Center(BOTH)
        pane: SizedPanel = self.GetContentsPane()

        pane.SetSizerType('vertical')

        book: Notebook = Notebook(pane, ID_ANY, style=BK_DEFAULT | NB_TOP)

        tokensConfigurationPanel: TokensConfigurationPanel = TokensConfigurationPanel(
            book)
        todoistConfigurationPanel: TodoistConfigurationPanel = TodoistConfigurationPanel(
            book)
        gitHubConfigurationPanel: GitHubConfigurationPanel = GitHubConfigurationPanel(
            book)

        book.AddPage(tokensConfigurationPanel, 'Tokens', select=True)
        book.AddPage(todoistConfigurationPanel, 'Todoist', select=False)
        book.AddPage(gitHubConfigurationPanel, 'GitHub', select=False)

        self.SetButtonSizer(self.CreateStdDialogButtonSizer(OK | CANCEL))

        self.Fit()
        self.SetMinSize(self.GetSize())

        self.Bind(EVT_BUTTON, self.__onCmdOk, id=ID_OK)
        self.Bind(EVT_BUTTON, self.__onClose, id=ID_CANCEL)
        self.Bind(EVT_CLOSE, self.__onClose)
コード例 #15
0
class ApplicationFrame(Frame):

    HELP_MENU_ID: int = wxNewIdRef()

    def __init__(self, parent: Window, wxID: int, title: str):

        self._preferences: Preferences = Preferences()
        appSize: Size = Size(self._preferences.startupWidth,
                             self._preferences.startupHeight)

        super().__init__(parent=parent,
                         id=wxID,
                         title=title,
                         size=appSize,
                         style=DEFAULT_FRAME_STYLE | FRAME_EX_METAL)

        self.logger: Logger = getLogger(__name__)

        self._status = self.CreateStatusBar()
        self._status.SetStatusText('Ready!')

        self._createApplicationMenuBar()
        self._githubPanel, self._todoistPanel = self._createApplicationContentArea(
        )
        # self.SetThemeEnabled(True)

        x, y = self._preferences.appStartupPosition

        if x == str(Preferences.NO_DEFAULT_X) or y == str(
                Preferences.NO_DEFAULT_Y):
            self.Center(BOTH)  # Center on the screen
        else:
            appPosition: Tuple[int, int] = self._preferences.appStartupPosition
            self.SetPosition(pt=appPosition)

        self.Bind(EVT_CLOSE, self.Close)
        self.Bind(EVT_REPOSITORY_SELECTED, self._onRepositorySelected)
        self.Bind(EVT_ISSUES_SELECTED, self._onIssuesSelected)

    # noinspection PyUnusedLocal
    def Close(self, force=False):

        ourSize: Tuple[int, int] = self.GetSize()
        self._preferences.startupWidth = ourSize[0]
        self._preferences.startupHeight = ourSize[1]

        pos: Tuple[int, int] = self.GetPosition()
        self._preferences.appStartupPosition = pos

        self.Destroy()

    def _createApplicationMenuBar(self):

        menuBar: MenuBar = MenuBar()
        fileMenu: Menu = Menu()
        helpMenu: Menu = Menu()

        fileMenu.Append(ID_PREFERENCES, 'Configure',
                        'Configure Application IDs')
        fileMenu.AppendSeparator()
        fileMenu.Append(ID_EXIT, '&Quit', "Quit Application")

        helpMenu.Append(ApplicationFrame.HELP_MENU_ID, "&MiniHelp",
                        "Simple Help")
        helpMenu.AppendSeparator()
        helpMenu.Append(ID_ABOUT, '&About', 'Tell you about me')

        menuBar.Append(fileMenu, 'File')
        menuBar.Append(helpMenu, 'Help')

        self.SetMenuBar(menuBar)

        self.Bind(EVT_MENU, self._onMiniHelp, id=ApplicationFrame.HELP_MENU_ID)
        self.Bind(EVT_MENU, self._onConfigure, id=ID_PREFERENCES)
        self.Bind(EVT_MENU, self._onAbout, id=ID_ABOUT)
        self.Bind(EVT_MENU, self.Close, id=ID_EXIT)

    def _createApplicationContentArea(
            self) -> Tuple[GitHubPanel, TodoistPanel]:

        leftPanel: GitHubPanel = GitHubPanel(self)
        rightPanel: TodoistPanel = TodoistPanel(self)

        mainSizer: BoxSizer = BoxSizer(orient=HORIZONTAL)
        mainSizer.Add(leftPanel, 1, EXPAND)
        mainSizer.Add(rightPanel, 1, EXPAND)

        # noinspection PyUnresolvedReferences
        self.SetSizer(mainSizer)
        # mainSizer.Fit(self)       # Don't do this or setting of frame size won't work

        return leftPanel, rightPanel

    # noinspection PyUnusedLocal
    def _onRepositorySelected(self, event: RepositorySelectedEvent):

        self.logger.info(
            f'Clear the github issues list and todoist panel selection lists')

        self._githubPanel.clearIssues()
        self._todoistPanel.clearTasks()

    def _onIssuesSelected(self, event: IssuesSelectedEvent):

        adapterTaskInfo: List[TaskInfo] = self.__convertToTasksToClone(
            event.selectedSimpleGitIssues)
        cloneInformation: CloneInformation = CloneInformation()

        cloneInformation.repositoryTask = event.repositoryName
        cloneInformation.milestoneNameTask = event.milestoneName
        cloneInformation.tasksToClone = adapterTaskInfo

        self.logger.warning(f'{event.selectedSimpleGitIssues=}')

        self._todoistPanel.tasksToClone = cloneInformation

    # noinspection PyUnusedLocal
    def _onMiniHelp(self, event: CommandEvent):

        dlg: DlgHelp = DlgHelp(self)
        dlg.ShowModal()

    # noinspection PyUnusedLocal
    def _onConfigure(self, event: CommandEvent):

        dlg: DlgConfigure = DlgConfigure(self)
        if dlg.ShowModal() == OK:
            preferences: Preferences = Preferences()
            todoistToken: str = preferences.todoistApiToken
            githubToken: str = preferences.githubApiToken
            gitHubUserName: str = preferences.githubUserName
            self.logger.debug(
                f'{todoistToken=} - {githubToken=} {gitHubUserName=}')

    # noinspection PyUnusedLocal
    def _onAbout(self, event: CommandEvent):

        dlg: DlgAbout = DlgAbout(parent=self)
        dlg.ShowModal()

    def __convertToTasksToClone(
            self,
            abbreviatedGitIssues: AbbreviatedGitIssues) -> List[TaskInfo]:
        adapterTaskInfo: List[TaskInfo] = []

        for simpleGitIssue in abbreviatedGitIssues:
            taskInfo: TaskInfo = TaskInfo()
            taskInfo.gitIssueName = simpleGitIssue.issueTitle
            taskInfo.gitIssueURL = simpleGitIssue.issueHTMLURL
            adapterTaskInfo.append(taskInfo)

        return adapterTaskInfo
コード例 #16
0
from wx import ID_OK
from wx import OK

from wx import TE_MULTILINE
from wx import TextCtrl

from wx.lib.sized_controls import SizedDialog

from wx import NewIdRef as wxNewIdRef
from wx.lib.sized_controls import SizedPanel

# noinspection PyProtectedMember
from org.pyut.general.Globals import _
from org.pyut.model.PyutMethod import SourceCode

TXT_CODE: int = wxNewIdRef()


class DlgEditCode(SizedDialog):
    """
    Dialog for the class comment edition.
    """

    def __init__(self, parent, wxID, sourceCode: SourceCode):
        """
        We'll modify pyutMethod on OK
        Args:
            parent:
            wxID:
            sourceCode:
        """
コード例 #17
0
ファイル: DlgEditComment.py プロジェクト: hasii2011/PyUt
from wx import TextCtrl
from wx import StaticText
from wx import Button
from wx import Point
from wx import Size
from wx import Dialog

from wx import NewIdRef as wxNewIdRef

# noinspection PyProtectedMember
from org.pyut.general.Globals import _

from org.pyut.model.PyutClass import PyutClass
from org.pyut.model.PyutInterface import PyutInterface

TXT_COMMENT = wxNewIdRef()


class DlgEditComment(Dialog):
    """
    Dialog for the class comment edition.
    """
    def __init__(self, parent, ID, pyutModel: Union[PyutClass, PyutInterface]):
        """

        Args:
            parent:
            ID:
            pyutModel:
        """