Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
p1-dta committed Oct 23, 2018
2 parents 26b7539 + d2d8a42 commit 4c29b75
Show file tree
Hide file tree
Showing 12 changed files with 662 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ venv.bak/

# mypy
.mypy_cache/

# Personalized
.idea/*
*.json
29 changes: 29 additions & 0 deletions EditGameSettingMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# ChiTrain
# Copyright (C) 2018 Dorian Turba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from tkinter import Menu

from EditLengthMenu import EditLengthMenu


class EditGameSettingMenu(Menu):
edit_length_menu: EditLengthMenu

def __init__(self):
Menu.__init__(self)
self.edit_length_menu = EditLengthMenu()
self.add_cascade(label='Game Length', menu=self.edit_length_menu)
35 changes: 35 additions & 0 deletions EditLengthMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# ChiTrain
# Copyright (C) 2018 Dorian Turba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from tkinter import Menu, IntVar


class EditLengthMenu(Menu):
game_length: IntVar

def __init__(self):
Menu.__init__(self)
self.game_length = IntVar(None, 10)
self.add_radiobutton(label="10 words (default)",
value=10,
variable=self.game_length)
self.add_radiobutton(label="25 words",
value=25,
variable=self.game_length)
self.add_radiobutton(label="50 words",
value=50,
variable=self.game_length)
58 changes: 58 additions & 0 deletions EditMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# ChiTrain
# Copyright (C) 2018 Dorian Turba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from functools import partial
from tkinter import Menu, Tk

import Window
import WordsSets
from EditGameSettingMenu import EditGameSettingMenu


class EditMenu(Menu):
main_menu: Menu
window: Window
show_set_menu: Menu
edit_set_menu: Menu
edit_game_settings_menu: EditGameSettingMenu

def __init__(self, main_menu) -> None:
Menu.__init__(self)
self.main_menu = main_menu
self.window = main_menu.parent
self.edit_set_menu = Menu(self)
self.edit_game_settings_menu = EditGameSettingMenu()
self.add_cascade(label='Edit Sets', menu=self.edit_set_menu)
self.add_cascade(label='Edit Game Settings',
menu=self.edit_game_settings_menu)
self.update_menu()

def update_menu(self) -> None:
if self.window.words_sets == 0:
self.entryconfig('Edit Sets', state='disabled')
else:
self.entryconfig('Edit Sets', state='normal')
for words_set in self.window.words_sets.w_s_array:
p_edit = partial(self.create_set_window, words_set)
self.edit_set_menu.add_cascade(label=words_set.get_name(),
command=p_edit)
return

def create_set_window(self, word_set: WordsSets):
window = Tk()
Window.SetWindow(self, word_set, window)
return
50 changes: 50 additions & 0 deletions FileMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# ChiTrain
# Copyright (C) 2018 Dorian Turba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from tkinter import Menu


def callback():
print('called the callback!')
pass


def import_pack():
print('called the import!')
pass


def export_pack():
print('called the export!')
pass


class FileMenu(Menu):
def __init__(self, window) -> None:
Menu.__init__(self)
self.add_command(label='Start Game', command=window.start)
self.add_command(label='Restart Game', command=callback)
self.add_command(label='Stop Game', command=callback)
self.add_separator()
self.add_command(label='New Set', command=callback)
self.add_command(label='Import Set Pack', command=import_pack)
self.add_command(label='Export Set Pack', command=export_pack)
self.add_separator()
self.add_command(label='Settings', command=callback)
self.add_separator()
self.add_command(label='Exit', command=window.ask_quit)
return
43 changes: 43 additions & 0 deletions HelpMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# ChiTrain
# Copyright (C) 2018 Dorian Turba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
import webbrowser
from tkinter import Menu


def callback():
print('called the callback!')
pass


def repository_redirect():
webbrowser.open('https://github.com/Vikka/ChiTrain')


def issue_redirect():
webbrowser.open('https://github.com/Vikka/ChiTrain/issues')


class HelpMenu(Menu):
def __init__(self) -> None:
Menu.__init__(self)
self.add_command(label='Getting Started', command=callback)
self.add_separator()
self.add_command(label='Github Repository',
command=repository_redirect)
self.add_command(label='Report Problem', command=issue_redirect)
self.add_command(label='About', command=callback)
41 changes: 41 additions & 0 deletions MainMenuBar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# ChiTrain
# Copyright (C) 2018 Dorian Turba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from tkinter import Menu

import EditMenu
import FileMenu
import HelpMenu
import Window


class MainMenuBar(Menu):
parent: Window
file_menu: FileMenu
edit_menu: EditMenu
help_menu: HelpMenu

def __init__(self, parent: Window) -> None:
Menu.__init__(self)
self.parent = parent
self.file_menu = FileMenu.FileMenu(self.parent)
self.edit_menu = EditMenu.EditMenu(self)
self.help_menu = HelpMenu.HelpMenu()
self.add_cascade(label='File', menu=self.file_menu)
self.add_cascade(label='Edit', menu=self.edit_menu)
self.add_cascade(label='Help', menu=self.help_menu)
return
Loading

0 comments on commit 4c29b75

Please sign in to comment.