Skip to content

Commit

Permalink
Merge pull request #3 from tifrueh/dev
Browse files Browse the repository at this point in the history
Merge for release 1.2.4
  • Loading branch information
tifrueh authored Feb 22, 2022
2 parents c9e02eb + 6b5d550 commit 67cafff
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 45 deletions.
22 changes: 10 additions & 12 deletions mlaatkst/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
from mlaatkst.menubar import Menubar
from mlaatkst.resource_helper import ResourceHelper

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
elif LanguageHelper.get_lang() == "ENG":
import mlaatkst.constants_eng as c


class App(tk.Tk):
def __init__(self):
super().__init__()

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
else:
import mlaatkst.constants_eng as c

# show the background image bg2.png from the resources folder in a label
self.bg_path = ResourceHelper.get_resource_path("bg2.png")
self.bg = tk.PhotoImage(file=self.bg_path, format="png")
Expand All @@ -51,17 +51,15 @@ def __init__(self):
self.titleLabel = ttk.Label(self, text=c.TITLE_LABEL, font=("TkHeadingFont", 26, "bold"))
self.titleLabel.grid(column=0, row=0, pady=40)

Menubar(self)

ControlFrame(self)


def main():
# start the main window specified above
app = App()

# add menubar
Menubar(app)

# place the control frame inside the window
ControlFrame(app)

# call tkinter mainloop of the main window
app.mainloop()

Expand Down
14 changes: 7 additions & 7 deletions mlaatkst/control_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
from mlaatkst.entry_frame import EntryFrame
from mlaatkst.language_helper import LanguageHelper

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
elif LanguageHelper.get_lang() == "ENG":
import mlaatkst.constants_eng as c


class ControlFrame(ttk.LabelFrame):
def __init__(self, container):
def __init__(self, container: tk.Tk):
super().__init__(container)

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
else:
import mlaatkst.constants_eng as c

# set the title of the frame
self["text"] = c.CONTROL_FRAME_TITLE

Expand Down
27 changes: 18 additions & 9 deletions mlaatkst/entry_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@

# the EntryFrame class which draws the entry frame lives here

import pyperclip as pyperclip
import tkinter as tk
from tkinter import ttk

from mlaatkst.citation_formatter import CitationFormatter
from mlaatkst.language_helper import LanguageHelper

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
elif LanguageHelper.get_lang() == "ENG":
import mlaatkst.constants_eng as c


class EntryFrame(ttk.Frame):
def __init__(self, container, option):
def __init__(self, container: tk.Tk, option):
super().__init__(container)

self.container = container

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
else:
import mlaatkst.constants_eng as c

# initialize option variable
# through which the control frame tells the program which frame to show
self.option = option
Expand Down Expand Up @@ -170,11 +172,18 @@ def format_citation(self):
def copy_citation(self):

# copy the contents of the resultLabel
self.container.clipboard_clear()
citation = self.resultLabel["text"]
pyperclip.copy(citation)
self.container.clipboard_append(citation)

def reset(self):

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
else:
import mlaatkst.constants_eng as c

# clear out all entries
self.nameAuthorEntry.delete(0, tk.END)
self.lastNameAuthorEntry.delete(0, tk.END)
Expand Down
14 changes: 7 additions & 7 deletions mlaatkst/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from mlaatkst.language_helper import LanguageHelper
from mlaatkst.settings_window import SettingsWindow

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
elif LanguageHelper.get_lang() == "ENG":
import mlaatkst.constants_eng as c


class Menubar(tk.Menu):
def __init__(self, container):
def __init__(self, container: tk.Tk):
super().__init__(container)

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
else:
import mlaatkst.constants_eng as c

self.container = container

# set this menubar to be the menubar of the containing object
Expand Down
16 changes: 9 additions & 7 deletions mlaatkst/settings_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

from mlaatkst.language_helper import LanguageHelper

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
elif LanguageHelper.get_lang() == "ENG":
import mlaatkst.constants_eng as c


class SettingsWindow(tk.Toplevel):
def __init__(self, container):
def __init__(self, container: tk.Tk):
super().__init__(container)

self.container = container

# choose the right constants file depending on the language
if LanguageHelper.get_lang() == "GER":
import mlaatkst.constants_de as c
else:
import mlaatkst.constants_eng as c

# set geometry and window title
self.geometry("300x200+100+100")
self.title(c.SETTINGS_TITLE)
Expand All @@ -46,9 +46,11 @@ def set_ger(self):
LanguageHelper.set_lang("GER")
self.destroy()
self.container.destroy()
self.container.__init__()

# method for setting the language to English and closing the program afterwards
def set_eng(self):
LanguageHelper.set_lang("ENG")
self.destroy()
self.container.destroy()
self.container.__init__()
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pyinstaller~=4.7
pyperclip~=1.8.2
pyinstaller~=4.7
2 changes: 1 addition & 1 deletion resources/lang.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GER
ENG

0 comments on commit 67cafff

Please sign in to comment.