예제 #1
0
    def show_information_gui(self):
        self.gui_window = Tk()
        self.gui_window.title('Cell Information: ({}, {})'.format(
            self.x, self.y))
        self.gui_window.geometry("400x300+0+0")
        self.gui_window.config(background='white')

        self.type_label = gui.Label(self.gui_window,
                                    text='Type: {}'.format(self.type))
        self.type_label.grid(row=0, sticky=W)

        self.owning_city_label = gui.Label(self.gui_window,
                                           text='Owning city: ')
        self.owning_city_label.grid(row=1, sticky=W)

        self.owning_nation_label = gui.Label(self.gui_window,
                                             text='Owning nation: ')
        self.owning_nation_label.grid(row=2, sticky=W)

        if self.owner is not None:
            self.owning_city_button = gui.Button(
                self.gui_window,
                text=self.owner.name,
                command=self.owner.show_information_gui)
            self.owning_nation_button = gui.Button(
                self.gui_window,
                text=self.owner.nation.name,
                command=self.owner.nation.show_information_gui)
        else:
            self.owning_city_button = gui.Button(self.gui_window, text='None')
            self.owning_nation_button = gui.Button(self.gui_window,
                                                   text='None')

        self.owning_city_button.grid(row=1, column=1, sticky=W)
        self.owning_nation_button.grid(row=2, column=1, sticky=W)

        self.building_capacity_label = gui.Label(
            self.gui_window,
            text='{} of {} filled.'.format(self.get_total_buiding_size(),
                                           self.building_capacity))
        self.building_capacity_label.grid(row=3)

        self.buildings_display = Listbox(self.gui_window)

        for building in self.buildings:
            self.buildings_display.insert(
                END, '{}: {}'.format(building.name, building.number))

        self.buildings_display.grid(row=4,
                                    column=0,
                                    columnspan=3,
                                    sticky=W + E)
예제 #2
0
    def show_information_gui(self):
        self.gui_window = Tk()
        self.gui_window.title('Culture of {}'.format(self.nation.name))
        self.gui_window.geometry("700x750+0+0")
        self.gui_window.config(background='white')

        self.gui_window.columnconfigure(2, weight=1)
        self.gui_window.rowconfigure(2, weight=1)

        self.nation_label = gui.Label(self.gui_window, text='Nation:')
        self.nation_label.grid(row=0, column=0, sticky=W)

        self.nation_button = gui.Button(
            self.gui_window,
            text=self.nation.name.short_name(),
            command=self.nation.show_information_gui)
        self.nation_button.grid(row=0, column=1, sticky=W)

        self.art_label = gui.Label(self.gui_window, text='Art:')
        self.art_label.grid(row=1, column=0, sticky=W)

        self.art_display = Listbox(self.gui_window)
        self.art_display.grid(row=2,
                              column=0,
                              columnspan=3,
                              sticky=N + S + E + W)
        self.art_display.bind('<Double-Button-1>', self.select_art)

        self.update_art_display()
예제 #3
0
    def __init__(self):
        self.parent = Tk()
        self.parent.title('History Generator')
        self.parent.geometry("450x260+0+0")

        self.parent.config(background='white')

        self.main_label = gui.Label(self.parent, text='History Generator:')
        self.main_label.config(font=(None, 32), fg='#f4ce42')
        self.main_label.pack()

        self.start_new_button = gui.Button(self.parent,
                                           text='[S]tart New',
                                           command=self.start_new)
        self.start_new_button.pack()

        self.load_var = StringVar()
        self.load_entry = Entry(self.parent, textvariable=self.load_var)
        self.load_entry.pack()
        self.load_button = gui.Button(self.parent,
                                      text='[L]oad',
                                      command=self.load)
        self.load_button.pack()

        self.archaeology_button = gui.Button(self.parent,
                                             text='[A]rchaeology',
                                             command=self.archaeology)
        self.archaeology_button.pack()

        self.exit_button = gui.Button(self.parent,
                                      text='[E]xit',
                                      command=self.parent.destroy)
        self.exit_button.pack()

        # Set up the hot keys
        self.parent.bind('S', lambda _: self.start_new())
        self.parent.bind('s', lambda _: self.start_new())
        self.parent.bind('L', lambda _: self.load())
        self.parent.bind('l', lambda _: self.load())
        self.parent.bind('A', lambda _: self.archaeology())
        self.parent.bind('a', lambda _: self.archaeology())
        self.parent.bind('E', lambda _: self.parent.destroy())
        self.parent.bind('e', lambda _: self.parent.destroy())

        self.parent.mainloop()
예제 #4
0
    def __init__(self, alien_lang, text_to_translate):
        self.parent = Tk()
        self.parent.title('Archaeology')
        self.parent.geometry('{}x{}+0+0'.format(utility.DISPLAY_WIDTH,
                                                utility.DISPLAY_HEIGHT))
        self.parent.config(background='white')

        self.text_to_translate = text_to_translate
        self.alien_lang = alien_lang

        # Create the actual gui
        self.alien_text = gui.Label(self.parent, text=text_to_translate)
        self.alien_text.grid(row=0, column=3, rowspan=6, sticky=W)

        self.english_text = gui.Label(self.parent, text=text_to_translate)
        self.english_text.grid(row=7, column=3, rowspan=6, sticky=W)
        self.alien_var = StringVar()
        self.alien_label = gui.Label(self.parent, text='Alien:')
        self.alien_label.grid(row=0, column=0, sticky=W + S)
        self.alien_box = Entry(self.parent, textvariable=self.alien_var)
        self.alien_box.grid(row=1, column=0, sticky=N)

        self.english_var = StringVar()
        self.english_label = gui.Label(self.parent, text='English:')
        self.english_label.grid(row=0, column=1, sticky=W + S)
        self.english_box = Entry(self.parent, textvariable=self.english_var)
        self.english_box.grid(row=1, column=1, sticky=N)

        self.translate_button = gui.Button(self.parent,
                                           text='Translate',
                                           command=self.test_translation)
        self.translate_button.grid(row=2, column=0, sticky=N)

        # All of the things we've guessed so far
        self.replacements = {}

        self.refresh_text()
예제 #5
0
    def __init__(self):
        events.main = self

        self.old_nations = {}

        self.year = 1
        self.month = 1
        self.day = 1
        self.hour = 0
        self.minute = 0

        self.parent = Tk()
        self.parent.title('Year: 0')
        self.parent.geometry("{}x{}+0+0".format(utility.DISPLAY_WIDTH, utility.DISPLAY_HEIGHT))
        self.parent.config(background='white')

        self.after_id = 0
        self.advance_num = 0

        self.ids = {}

        self.battles = []

        self.battle_history = []
        self.treaties = []

        self.cells = []

        self.nations = []
        self.coninents = []
        self.religions = []

        self.is_continuous = False
        self.run_until_battle = False
        self.advancing = False
        self.graphical_battles = True
        self.fast_battles = False

        self.world_name = ''

        self.db = None  # The DB connection. Will be created after setup so we can give it a real name.

        # Set up the GUI

        self.event_log_box = Listbox(self.parent, height=10)
        self.event_log = EventLog(self, self.db, self.event_log_box)

        self.parent.columnconfigure(3, weight=1)
        self.parent.rowconfigure(13, weight=1)

        self.parent.bind('<MouseWheel>', self.on_vertical)
        self.parent.bind('<Shift-MouseWheel>', self.on_horizontal)
        self.parent.bind('<Left>', lambda _: self.scroll_canvas(-utility.SCROLL_SPEED, 0))
        self.parent.bind('<Right>', lambda _: self.scroll_canvas(utility.SCROLL_SPEED, 0))
        self.parent.bind('<Up>', lambda _: self.scroll_canvas(0, -utility.SCROLL_SPEED))
        self.parent.bind('<Down>', lambda _: self.scroll_canvas(0, utility.SCROLL_SPEED))

        self.canvas = Canvas(self.parent, bd=1, relief=RIDGE, scrollregion=(0, 0, utility.S_WIDTH, utility.S_HEIGHT))
        self.canvas.bind('<Button-1>', self.get_cell_information)
        self.canvas.config(background='white')

        self.canvas.grid(row=0, column=3, rowspan=14, sticky=W + E + N + S)

        self.continuous = gui.Button(self.parent, text="[R]un until battle", command=self.toggle_run_until_battle)
        self.continuous.grid(row=0, sticky=W)

        self.minimize_battles = gui.Checkbutton(self.parent, text='Minimize battle windows',
                                                command=self.toggle_minimize_battles)
        self.minimize_battles.grid(row=0, column=1, columnspan=2, sticky=W)

        self.religion_history_button = gui.Button(self.parent, text="R[e]ligion history",
                                                  command=self.open_religion_history_window)
        self.religion_history_button.grid(row=2, column=0, sticky=W)

        self.world_history_button = gui.Button(self.parent, text="[W]orld history",
                                               command=self.open_world_history_window)
        self.world_history_button.grid(row=2, column=1, sticky=W)

        self.zoom_label = gui.Label(self.parent, text='Zoom (Cell Size):')
        self.zoom_label.grid(row=3, column=0, sticky=W)

        self.graphical_battles_checkbox = gui.Checkbutton(self.parent, text='Graphical Battles',
                                                          command=self.toggle_graphical_battles)
        self.graphical_battles_checkbox.grid(row=3, column=1, sticky=W)
        self.graphical_battles_checkbox.select()  # Graphical battles are the default

        self.fast_battles_checkbox = gui.Checkbutton(self.parent, text='Fast Battles', command=self.toggle_fast_battles)
        self.fast_battles_checkbox.grid(row=4, column=1, sticky=W)

        self.zoom_scale = gui.Scale(self.parent, from_=1, to_=20, orient=HORIZONTAL)
        self.zoom_scale.grid(row=4, column=0, sticky=W)
        self.zoom_scale.bind('<ButtonRelease-1>', self.zoom)
        self.zoom_scale.set(utility.CELL_SIZE)

        self.advance_button = gui.Button(self.parent, text="[A]dvance Step", command=self.advance_once)
        self.advance_button.grid(row=5, sticky=W)

        self.run_continuously_checkbutton = gui.Checkbutton(self.parent, text='Run continuously',
                                                            command=self.toggle_continuous)
        self.run_continuously_checkbutton.grid(row=5, column=1, sticky=W)

        self.simulation_speed_label = gui.Label(self.parent, text='Simulation Speed (ms):')
        self.simulation_speed_label.grid(row=6, column=0, sticky=W)

        self.save_button = gui.Button(self.parent, text='[S]ave', command=self.save)
        self.save_button.grid(row=6, column=1, sticky=W)

        self.delay = gui.Scale(self.parent, from_=10, to_=1000, orient=HORIZONTAL)
        self.delay.grid(row=7, sticky=W)
        self.delay.set(DEFAULT_SIMULATION_SPEED)

        self.advance_time_button = gui.Button(self.parent, text='Advance [B]y:', command=self.run_to)
        self.advance_time_button.grid(row=8, column=0, sticky=W)

        self.years_box = Entry(self.parent)
        self.years_box.grid(row=9, column=0, sticky=W)

        self.nation_selector_label = gui.Label(self.parent, text='Nations:')
        self.nation_selector_label.grid(row=10, column=0, sticky=W)

        self.nation_selector = Listbox(self.parent)
        self.nation_selector.grid(row=11, column=0, columnspan=3, sticky=W + E)

        self.nation_selector.bind('<Double-Button-1>', self.select_nation)

        self.event_log_box.grid(row=15, column=3, stick=W + E)

        # Set up hotkeys
        self.parent.bind('R', lambda _: self.toggle_run_until_battle())
        self.parent.bind('r', lambda _: self.toggle_run_until_battle())
        self.parent.bind('E', lambda _: self.open_religion_history_window())
        self.parent.bind('e', lambda _: self.open_religion_history_window())
        self.parent.bind('W', lambda _: self.open_world_history_window())
        self.parent.bind('w', lambda _: self.open_world_history_window())
        self.parent.bind('A', lambda _: self.advance_once())
        self.parent.bind('a', lambda _: self.advance_once())
        self.parent.bind('S', lambda _: self.save())
        self.parent.bind('s', lambda _: self.save())
        self.parent.bind('B', lambda _: self.run_to())
        self.parent.bind('b', lambda _: self.run_to())

        self.refresh_nation_selector()

        self.setup()
예제 #6
0
    def show_information_gui(self):
        self.gui_window = Tk()
        self.gui_window.title(self.name)
        self.gui_window.geometry("600x375+0+0")
        self.gui_window.config(background='white')

        self.gui_window.columnconfigure(2, weight=1)

        x, y = self.get_average_position()
        self.position_label = gui.Label(self.gui_window,
                                        text='Position: ({}, {})'.format(x, y))
        self.position_label.grid(row=0, sticky=W)

        self.resources_display = Listbox(self.gui_window)

        for resource in self.resources:
            self.resources_display.insert(
                END, '{}: {}'.format(resource, self.resources[resource]))

        self.resources_display.config(height=len(self.resources))
        self.resources_display.grid(row=0,
                                    column=1,
                                    rowspan=4,
                                    columnspan=3,
                                    sticky=N + S + W + E)

        self.size_label = gui.Label(self.gui_window,
                                    text='Size: {}'.format(
                                        self.total_cell_count()))
        self.size_label.grid(row=1, sticky=W)

        self.population_label = gui.Label(
            self.gui_window,
            text='Population: {} of {}'.format(
                self.population, self.calculate_population_capacity()))
        self.population_label.grid(row=3, sticky=W)

        self.army_label = gui.Label(self.gui_window,
                                    text='Army: {}'.format(self.army.size()))
        self.army_label.grid(row=4, sticky=W)

        self.morale_label = gui.Label(self.gui_window,
                                      text='Morale: {}'.format(self.morale))
        self.morale_label.grid(row=5, sticky=W)

        self.buildings_display = Listbox(self.gui_window)

        self.building_counts = {}

        for cell in self.cells:
            for building in cell.buildings:
                if building.name in self.building_counts:
                    self.building_counts[building.name] += building.number
                else:
                    self.building_counts[building.name] = building.number

        for building in self.building_counts:
            self.buildings_display.insert(
                END, '{}: {}'.format(building, self.building_counts[building]))

        self.buildings_display.grid(row=4,
                                    column=1,
                                    columnspan=3,
                                    rowspan=2,
                                    sticky=W + E)

        self.nation_label = gui.Label(self.gui_window, text='Nation: ')
        self.nation_label.grid(row=6, sticky=W)

        self.nation_button = gui.Button(
            self.gui_window,
            text=self.nation.name,
            command=self.nation.show_information_gui)
        self.nation_button.grid(row=6, column=1, sticky=W)

        all_events = event_analysis.find_city_mentions(
            self.parent.event_log, [self.name] + self.merges)
        all_events = all_events.search('name',
                                       r'Attack|CityFounded|CityMerged')
        all_events = sorted(all_events.event_list,
                            key=lambda event: event.date)

        self.event_log_display = Listbox(self.gui_window)

        for event in all_events:
            self.event_log_display.insert(END, event.text_version())

        self.event_log_display.grid(row=7,
                                    column=0,
                                    columnspan=3,
                                    rowspan=10,
                                    sticky=W + E)
예제 #7
0
    def show_information_gui(self):
        self.gui_window = Tk()
        self.gui_window.title(self.name.short_name())
        self.gui_window.geometry("500x400+0+0")
        self.gui_window.config(background='white')

        self.gui_window.columnconfigure(5, weight=1)

        self.full_name = gui.Label(self.gui_window,
                                   text='Full name: {}'.format(self.name))
        self.full_name.grid(row=0, columnspan=6, sticky=W)

        self.age_label = gui.Label(self.gui_window,
                                   text='Age: {}'.format(self.age))
        self.age_label.grid(row=1, sticky=W)

        self.ruler_label = gui.Label(self.gui_window,
                                     text='Ruler: {}'.format(self.ruler))
        self.ruler_label.grid(row=2, columnspan=6, sticky=W)

        self.money_label = gui.Label(self.gui_window,
                                     text='Money: {}'.format(int(self.money)))
        self.money_label.grid(row=3, columnspan=2, sticky=W)

        self.morale_label = gui.Label(self.gui_window,
                                      text='Morale: {}'.format(self.morale))
        self.morale_label.grid(row=4, columnspan=2, sticky=W)

        self.religion_label = Label(self.gui_window, text='Main Religion: ')
        self.religion_label.grid(row=5, sticky=W)

        if self.main_religion is not None:
            self.religion_button = Button(
                self.gui_window,
                text=self.main_religion.name,
                command=self.main_religion.show_information_gui)
            self.religion_button.grid(row=5, column=1, sticky=W)
        else:
            self.religion_label = Label(self.gui_window,
                                        text='Religion: Secular')

        self.army_structure_button = gui.Button(
            self.gui_window,
            text='Army',
            command=self.army_structure.show_information_gui)
        self.army_structure_button.grid(row=6, column=0, sticky=W)

        self.culture_button = gui.Button(
            self.gui_window,
            text='Culture',
            command=self.culture.show_information_gui)
        self.culture_button.grid(row=6, column=1, sticky=W)

        self.army_structure_button = gui.Button(
            self.gui_window,
            text='Troop Tree',
            command=self.show_troop_tree_gui)
        self.army_structure_button.grid(row=6, column=2, sticky=W)

        self.display_selector_label = gui.Label(self.gui_window,
                                                text='Display:')
        self.display_selector_label.grid(row=7, sticky=W)

        self.event_display_button = gui.Button(self.gui_window,
                                               text='Events',
                                               command=self.display_events)
        self.event_display_button.grid(row=8, column=0, sticky=W)

        self.people_display_button = gui.Button(self.gui_window,
                                                text='People',
                                                command=self.display_people)
        self.people_display_button.grid(row=8, column=1, sticky=W)

        self.city_display_button = gui.Button(self.gui_window,
                                              text='Cities',
                                              command=self.display_cities)
        self.city_display_button.grid(row=8, column=2, sticky=W)

        self.trade_display_button = gui.Button(self.gui_window,
                                               text='Trade',
                                               command=self.display_trade)
        self.trade_display_button.grid(row=8, column=3, sticky=W)

        self.war_display_button = gui.Button(self.gui_window,
                                             text='War',
                                             command=self.display_war)
        self.war_display_button.grid(row=8, column=4, sticky=W)

        self.listbox_display = Listbox(self.gui_window)
        self.listbox_display.grid(row=9, sticky=E + W, columnspan=6)

        self.listbox_display.bind('<Double-Button-1>', self.selected)
예제 #8
0
    def show_information_gui(self):
        self.gui_window = Tk()
        self.gui_window.title(self.name)
        self.gui_window.geometry("400x625+0+0")
        self.gui_window.config(background='white')

        self.ranged_label = gui.Label(self.gui_window, text='Is ranged: {}'.format(self.ranged))
        self.ranged_label.grid(row=0, sticky=W)

        self.mount_label = gui.Label(self.gui_window, text='Mount: {}'.format(self.mount.name))
        self.mount_label.grid(row=1, sticky=W)

        self.strength_label = gui.Label(self.gui_window, text='Strength: {}'.format(self.strength))
        self.strength_label.grid(row=2, sticky=W)

        self.health_label = gui.Label(self.gui_window, text='Health: {}'.format(self.health))
        self.health_label.grid(row=3, sticky=W)

        self.discipline_label = gui.Label(self.gui_window, text='Discipline: {}'.format(self.discipline))
        self.discipline_label.grid(row=4, sticky=W)


        self.discipline_label = gui.Label(self.gui_window, text='Cost: {}'.format(self.get_soldier_cost()))
        self.discipline_label.grid(row=5, sticky=W)

        self.arrangement = gui.Label(self.gui_window, text='Arrangement: {}x{}'.format(self.rank_size, self.ranks))
        self.arrangement.grid(row=6, sticky=W)

        self.arrangement_canvas = Canvas(self.gui_window, width = (self.rank_size + 1) * (TROOP_RADIUS + 1), height= (self.ranks + 1) * (TROOP_RADIUS + 1))
        self.arrangement_canvas.config(background='white')
        self.arrangement_canvas.grid(row=7, sticky=W)

        for x in xrange(1, self.rank_size + 1):
            for y in xrange(1, self.ranks + 1):
                base_x, base_y = x * (TROOP_RADIUS + 1), y * (TROOP_RADIUS + 1)
                self.arrangement_canvas.create_oval(base_x, base_y, base_x + TROOP_RADIUS, base_y + TROOP_RADIUS)

        self.upgrade_label = gui.Label(self.gui_window, text='Upgrades:')
        self.upgrade_label.grid(row=8, sticky=W)

        self.upgrade_buttons = []
        for (i, upgrade) in enumerate(self.upgrades):
            new_upgrade_button = gui.Button(self.gui_window, text=upgrade.name, command=upgrade.show_information_gui)
            new_upgrade_button.grid(row=9, column=i, sticky=W)

            self.upgrade_buttons.append(new_upgrade_button)

        self.history_choice = StringVar()
        self.history_choice.set(self.stringify_history(0))

        self.stats_label = gui.Label(self.gui_window, text='Stats:')
        self.stats_label.grid(row=10, column=0, sticky=W)

        self.stats_choice = OptionMenu(self.gui_window, self.history_choice, *map(self.stringify_history, range(len(self.arms_history))))
        self.stats_choice.config(background='white')
        self.stats_choice['menu'].config(background='white')
        self.stats_choice.grid(row=10, column=1, sticky=W)

        self.stats_select = gui.Button(self.gui_window, text='Select', command=self.select_history)
        self.stats_select.grid(row=10, column=2, sticky=W)

        self.stats_display = Listbox(self.gui_window)
        self.stats_display.grid(row=11, column=0, columnspan=3, sticky=W+E)

        self.select_history()