Пример #1
0
def main():
    root = Tk()
    root.minsize(800,600)
    app = MainWindow(root)
    
    infotab = Tabs(app)
    k_map = Map(app, "Maps\Kingston_z1.gif", (44.2296,76.4928), (44.2224,76.4856), 626, 872)
    u_map = Map(app, "Maps\Green_River_z2.gif", (38.850,110.25), (38.830,110.21), 1250, 810)
    u_map_big = Map(app, "Maps\Green_River_Launch_Map.gif", (38.8440, 110.255), (38.8296, 110.205), 7137, 2657)
    u_map_2016 = Map(app, "Maps\GR_2016.gif", (38.82,109.99), (38.77,109.88), 1240, 666)
    
    mapplot = MapGraph(app,(u_map_2016, u_map_big, u_map, k_map), index = 0)
    dataplot = Datamonitor(app)
    altplot = Plot(app, ylabel="Altitude (m)", xinterval=float("inf"), numy=2)
    
    battery_meter = Meter(app, 4.3, 3)
    serialmonitor = SerialMonitor(app, altplot, mapplot, dataplot, battery_meter)
    infotab.add_tab(mapplot, "Map")
    infotab.add_tab(dataplot, "Plots")
    
    widgets = (infotab, altplot, serialmonitor)
    app.setwidgets(widgets)
    #serialmonitor.scan_ports()
    app.bind("<Configure>", app.fit_widgets())
    app.mainloop()
 def _render_panes(self):
     self.columnconfigure('all', weight=1)
     self.rowconfigure('all', weight=1)
     menu_width = int((self.height / 3) - 10)
     self.status_bar = LogFrame(self, menu_width)
     self.status_bar.grid(row=1, column=0, sticky=S + W, padx=5, pady=5)
     if self.is_game_in_progress.get():
         self._render_game_board()
     else:
         self._render_game_board_placeholder()
     self.menu = Tabs(self, menu_width)
     self.menu.grid(row=0, column=0, sticky=N + W, padx=5, pady=5)
     if self.screen_ratio == 'wide':
         ship_width = self.width - menu_width - self.board_width - 30
         self.ship = Frame(self, width=ship_width)
         self.ship.grid(row=0,
                        column=2,
                        rowspan=2,
                        sticky=W + N + E,
                        padx=5,
                        pady=5)
Пример #3
0
    def __init__(self):
        super(Layout, self).__init__()
        self.taskwidget = TasksWidget([])
        self.scrollarea = QScrollArea()

        # Tabs
        self.tab = Tabs()

        # Calendar init
        self.calendar = QCalendarWidget()
        self.calendar.setMaximumHeight(200)
        self.calendar.selectionChanged.connect(self.tabCheck)

        # Layouts
        self.vb = QVBoxLayout()
        # Splitters
        self.vsplitter = QSplitter()
        self.bottomsplitter = QSplitter(Qt.Vertical)

        self.dragging = False
        self.dragtext = ''

        # Keeping track of changed and not currently saved tables
        self.notsaved = []
Пример #4
0
                line = q2.get_nowait()
                parse_qdebug(line, True)
            except Empty:
                pass

        try:
            line = q1.get(timeout=0.1)
            parse_qdebug(line)
        except Empty:
            pass


s = session.Session()
content = []

tabs = Tabs()
s.addPage(tabs)

elems = base.ElementList()
warninglist = base.ElementViewSlice(elems)

tabs.add_tab(name = "Ring-KDE" , page= warninglist )
tabs.add_tab(name = "Daemon"   , page= None )
tabs.add_tab(name = "System"   , page= None )

# Display info
class InfoPage(Page):
    def __init__(self):
        Page.__init__(self)
        self.height = 8
        self._entry = None
Пример #5
0
    def config_widget(self, user_config):
        config = deepcopy(config_defaults)
        config.update(user_config)

        self.layout = get_layout(config["layout"])
        self.setLayout(self.layout)
        self.groups = []
        self.group_names = dict()
        self.p = Parameter.create(name='params', type='group')

        if config["tabs_enabled"]:
            tabs = Tabs()
            self.layout.addWidget(tabs)

        for gconf in config["groups"]:
            if not gconf["enabled"]:
                continue
            group = deepcopy(group_default)
            group.update(gconf)

            if group["box_enabled"]:
                widget = QtGui.QGroupBox(group["group_name"])
                # widget.setSizePolicy(
                #     QtGui.QSizePolicy(
                #         QtGui.QSizePolicy.Maximum,
                #         QtGui.QSizePolicy.Maximum
                #     )
                # )
                self.group_names[group["group_name"]] = widget
                widget.setCheckable(group["checkable"])
            else:
                widget = QtGui.QWidget()

            if group["splitter_enabled"]:
                splitter = QtGui.QSplitter()
                splitter.setStretchFactor(0, 0)
                splitter.setStretchFactor(1, 1)

            layout = get_layout(group["layout"])
            widget.setLayout(layout)
            self.groups.append(layout)

            for io in group["items"]:
                self.p.addChild(io)
                iow = make_funcs[io["class"]](io,
                                              callback=self.generic_callback)
                self.io_widgets[io["name"]] = iow
                if group["splitter_enabled"]:
                    splitter.addWidget(iow)
                else:
                    layout.addWidget(iow)

                io["added"] = True
                # if instance["type"] is not None:
                #   self.p.[io["name"]]

            if group["scrollable"]:
                widget2 = QtGui.QGroupBox(group["group_name"])
                layout2 = get_layout(group["layout"])
                widget.setTitle("")
                scroll = QtGui.QScrollArea()
                scroll.setWidget(widget)
                scroll.setWidgetResizable(True)
                scroll.setAlignment(QtCore.Qt.AlignTop)
                scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
                layout2.addWidget(scroll)
                widget2.setLayout(layout2)
                widget = widget2

            if config['tabs_enabled']:
                tabs.add_tab(widget, group["group_name"])
            elif "group_layout_params" in config.keys():
                self.layout.addWidget(
                    widget,
                    *config["group_layout_params"][group["group_name"]])
            elif group["splitter_enabled"]:
                self.layout.addWidget(splitter)
            else:
                self.layout.addWidget(widget)

            # self.p.sigTreeStateChanged.connect(change)
        return self.p, config
Пример #6
0
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import base
import json
import session
from pager import Pager
from editor import Editor
from basicpage import BasicPage
from tabs import Tabs
from help import Help

s = session.Session()
content = []

toptabs = Tabs()
toptabs.height = 10
toptabs.expand = False
s.addPage(toptabs)


elems = base.ElementList()


elems.add(base.Element( ["locat"] ))
elems.add(base.Element( ["bobcat"] ))
elems.add(base.Element( ["locat"] ))


bplist = base.ElementViewSlice(elems)
toptabs.add_tab(name = "Commands" , page= bplist )
Пример #7
0
from help import Help

rows_, columns_ = os.popen('stty size', 'r').read().split()
rows, columns = int(rows_), int(columns_)

s = session.Session()
content = []

# Setup the table
elems = base.ElementList()
elems.alignColumn(0, base.Align.LEFT )
elems.alignColumn(1, base.Align.RIGHT)
elems.alignColumn(2, base.Align.RIGHT)
warninglist = base.ElementViewSlice(elems)

source = Tabs()
source.expand = False
source.height = 10
s.addPage(source)

source.add_tab(name = "Clazy"     , page= warninglist )
source.add_tab(name = "GCC"       , page= None        )
source.add_tab(name = "Krazy2"    , page= None        )
source.add_tab(name = "Coverity"  , page= None        )
source.add_tab(name = "MemCheck"  , page= None        )
source.add_tab(name = "HeapTrack" , page= None        )
#source.add_tab(name = "Static"    , page= None        )

# Create a waning list
with open("/tmp/clazy.json", 'r') as f:
    content = json.load(f)
Пример #8
0
  def config_widget(self, user_config):
    config = deepcopy(config_defaults)
    config.update(user_config)

    self.layout = get_layout(config["layout"])
    self.setLayout(self.layout)
    self.groups = []
    self.group_names = dict()
    self.p = Parameter.create(name='params', type='group')

    if config["tabs_enabled"]:
      tabs = Tabs()
      self.layout.addWidget(tabs)

    for gconf in config["groups"]:
      if not gconf["enabled"]:
        continue
      group = deepcopy(group_default)
      group.update(gconf)

      if group["box_enabled"]:
        widget = QtGui.QGroupBox(group["group_name"])
        # widget.setSizePolicy(
        #     QtGui.QSizePolicy(
        #         QtGui.QSizePolicy.Maximum,
        #         QtGui.QSizePolicy.Maximum
        #     )
        # )
        self.group_names[group["group_name"]] = widget
        widget.setCheckable(group["checkable"])
      else:
        widget = QtGui.QWidget()

      if group["splitter_enabled"]:
        splitter = QtGui.QSplitter()
        splitter.setStretchFactor(0, 0)
        splitter.setStretchFactor(1, 1)

      layout = get_layout(group["layout"])
      widget.setLayout(layout)
      self.groups.append(layout)

      for io in group["items"]:
        self.p.addChild(io)
        iow = make_funcs[io["class"]](io, callback=self.generic_callback)
        self.io_widgets[io["name"]] = iow
        if group["splitter_enabled"]:
          splitter.addWidget(iow)
        else:
          layout.addWidget(iow)

        io["added"] = True
        # if instance["type"] is not None:
        #   self.p.[io["name"]]

      if group["scrollable"]:
        widget2 = QtGui.QGroupBox(group["group_name"])
        layout2 = get_layout(group["layout"])
        widget.setTitle("")
        scroll = QtGui.QScrollArea()
        scroll.setWidget(widget)
        scroll.setWidgetResizable(True)
        scroll.setAlignment(QtCore.Qt.AlignTop)
        scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        layout2.addWidget(scroll)
        widget2.setLayout(layout2)
        widget = widget2

      if config['tabs_enabled']:
        tabs.add_tab(widget, group["group_name"])
      elif "group_layout_params" in config.keys():
        self.layout.addWidget(widget, *config["group_layout_params"][group["group_name"]])
      elif group["splitter_enabled"]:
        self.layout.addWidget(splitter)
      else:
        self.layout.addWidget(widget)

      # self.p.sigTreeStateChanged.connect(change)
    return self.p, config
Пример #9
0
class Layout(QWidget):
    def __init__(self):
        super(Layout, self).__init__()
        self.taskwidget = TasksWidget([])
        self.scrollarea = QScrollArea()

        # Tabs
        self.tab = Tabs()

        # Calendar init
        self.calendar = QCalendarWidget()
        self.calendar.setMaximumHeight(200)
        self.calendar.selectionChanged.connect(self.tabCheck)

        # Layouts
        self.vb = QVBoxLayout()
        # Splitters
        self.vsplitter = QSplitter()
        self.bottomsplitter = QSplitter(Qt.Vertical)

        self.dragging = False
        self.dragtext = ''

        # Keeping track of changed and not currently saved tables
        self.notsaved = []

    def initTasks(self, statuses):
        """Initializes and fills the task widget"""

        stats = []
        for status in statuses:
            group = TaskGroup(status)
            tasks = getTasks(status)
            for task in tasks:
                group.addTask(Task(task))
            stats.append(group)
        self.taskwidget.setGroups(stats)
        self.taskwidget.updateme()

    def create(self):
        """Binds together every layout and widget"""

        self.scrollarea.setWidget(self.taskwidget)
        self.scrollarea.setWidgetResizable(True)

        self.tab.openTab(1)

        self.vsplitter.addWidget(self.scrollarea)
        self.vsplitter.addWidget(self.tab)

        self.bottomsplitter.addWidget(self.vsplitter)
        self.bottomsplitter.addWidget(self.calendar)

        self.vb.addWidget(self.bottomsplitter)
        self.setLayout(self.vb)

    def mousePressEvent(self, event):
        """The 'mouse-press' part of tasks drag&drop feature"""

        if event.buttons() != Qt.RightButton:
            return
        rightclick = event.pos()
        scroll = self.scrollarea.verticalScrollBar().value()
        self.rightclickpos = rightclick + QPoint(0, scroll)
        self.dragging = True
        self.dragtext = self.taskwidget.getText(self.rightclickpos)

    def mouseReleaseEvent(self, event):
        """The 'mouse-release' part of tasks drag&drop feature"""

        if event.button() != Qt.RightButton:
            return
        if self.dragging:
            position = event.pos() - QPoint(self.taskwidget.geometry().width() + 55, 55)
            table = self.tab.currentWidget()
            if table.itemAt(position) is not None:
                table.itemAt(position).setText(self.dragtext)
        self.dragging = False

    def tabCheck(self):
        selectdate = self.calendar.selectedDate()
        startdate = helpers.fromDatetoQDate(global_vars.DAYFIRST)
        weeknum = helpers.getWeekDif(startdate, selectdate) + 1
        self.tab.openTab(weeknum)
from tkinter import Tk
from tkinter import ttk
from tabs import Tabs

root = Tk()
root.wm_title('GUI-For Gapminder')
#root.resizable(0,0)
#root.iconbitmap('.ico')
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
tbs = Tabs(master=root)
tbs.grid(sticky='nsew')
root.mainloop()
try:
    root.destroy()
except:
    pass
Пример #11
0
class Application(Tk):
    def __init__(self, debug_mode=0):
        Tk.__init__(self)
        self.engine = None
        self.language = None
        self.width = 0
        self.height = 0
        self.resolution_code = None
        self.is_full_screen = IntVar()
        self.screen_ratio = None
        self.resolution_list = []
        self.debug_mode = debug_mode
        if self.debug_mode:
            basicConfig(level=DEBUG)
            pil_logger = getLogger("PIL.PngImagePlugin")
            pil_logger.level = WARNING
        self.data_reader = DataReader(self)
        self._process_config()
        self.card_texts = {}
        self.ui_text_variables = {}
        self._load_text_variables()
        self.save_handler = SaveHandler(self)
        self.is_game_setup_in_progress = IntVar(value=0)
        self.is_game_in_progress = IntVar(value=0)
        self.is_turn_in_progress = IntVar(value=1)
        self._render_panes()
        self.is_game_in_progress.trace('w', self._follow_game_progress_change)
        self.is_turn_in_progress.trace('w', self._follow_turn_progress_change)
        self.players = {}
        self._text_placer()
        self.protocol("WM_DELETE_WINDOW", self.shutdown_ttk_repeat_fix)
        self.exit_in_progress = False

    @property
    def board_width(self):
        return self.height - 10

    def _process_config(self):
        settings = self.data_reader.load_settings()
        self.language = Languages.get_language_by_name(settings.language)
        s.language = Languages.get_language_by_name(settings.language)
        s.application_width = self.width = settings.width
        s.application_height = self.height = settings.height
        self.resolution_code = settings.resolution_code
        self.resolution_list = settings.resolution_list
        self.screen_ratio = self.resolution_code[:4]
        self.is_full_screen.set(settings.full_screen)
        self._fix_window_size()

    def _fix_window_size(self):
        self.minsize(self.width, self.height)
        self.maxsize(self.width, self.height)
        if self.is_full_screen.get():
            self._set_full_screen_position()
        else:
            self._set_windowed_position()

    def _set_full_screen_position(self):
        self.overrideredirect(1)
        self.geometry("{}x{}+0+0".format(self.width, self.height))

    def _set_windowed_position(self):
        self.overrideredirect(0)
        self.geometry("{}x{}+{}+{}".format(self.width, self.height, 100, 100))

    def _load_text_variable_values(self):
        text_variable_values = self.data_reader.load_dictionary(
            {
                Languages.HUNGARIAN.value: "hu",
                Languages.ENGLISH.value: "en",
                Languages.PIRATE.value: "arr"
            }[self.language],
            entry_type='textvariable')
        return text_variable_values

    def _load_text_variables(self):
        for term, translation in s.language.var_terms.items():
            self.ui_text_variables.setdefault(term,
                                              StringVar()).set(translation)

    def _text_placer(self):
        picked_nations = []
        self.title(s.language.title)
        self.menu.load_ui_texts()
        if self.is_game_setup_in_progress.get():
            picked_nations = self._save_game_setup_state()
        if self.is_game_setup_in_progress.get():
            self._reload_game_setup_state(picked_nations)
        if self.is_game_in_progress.get():
            self.menu.reset_game_tab()

    def _save_game_setup_state(self):
        picked_nations = []
        for i in range(6):
            empire_name = self.game_board.player_setups[i].empire_picker.get()
            if empire_name != '':
                current_empire = Empires.get_by_name(empire_name)
                picked_nations.append(current_empire)
            else:
                picked_nations.append('')
        return picked_nations

    def _reload_game_setup_state(self, picked_nations: List[Empire]):
        adjectives = [empire.value.adjective for empire in Empires]
        translated_adjectives = [
            s.language.get(adjective) for adjective in adjectives
        ]
        for index, picked_nation in enumerate(picked_nations):
            self.game_board.player_setups[index].empire_picker.config(
                value=translated_adjectives)
            if picked_nation:
                self.game_board.player_setups[index].empire_picker.set(
                    s.language.get(picked_nation.adjective))

    def set_new_language(self, new_language):
        if self.language == new_language:
            return
        self.language = new_language
        s.language = new_language
        self._load_text_variables()
        self._text_placer()
        self.card_texts = self.data_reader.load_cards_text()
        self.status_bar.log(s.language.new_language)
        self.data_reader.save_settings(new_language=new_language)

    def _render_panes(self):
        self.columnconfigure('all', weight=1)
        self.rowconfigure('all', weight=1)
        menu_width = int((self.height / 3) - 10)
        self.status_bar = LogFrame(self, menu_width)
        self.status_bar.grid(row=1, column=0, sticky=S + W, padx=5, pady=5)
        if self.is_game_in_progress.get():
            self._render_game_board()
        else:
            self._render_game_board_placeholder()
        self.menu = Tabs(self, menu_width)
        self.menu.grid(row=0, column=0, sticky=N + W, padx=5, pady=5)
        if self.screen_ratio == 'wide':
            ship_width = self.width - menu_width - self.board_width - 30
            self.ship = Frame(self, width=ship_width)
            self.ship.grid(row=0,
                           column=2,
                           rowspan=2,
                           sticky=W + N + E,
                           padx=5,
                           pady=5)

    def _render_game_board_placeholder(self):
        self.game_board = Frame(self,
                                width=self.board_width,
                                height=self.board_width)
        self.game_board.player_setups = []
        self.game_board.grid(row=0,
                             column=1,
                             rowspan=2,
                             sticky=N + W,
                             padx=5,
                             pady=5)

    def _render_game_board(self):
        self.game_board = Board(self, self.board_width)
        self.game_board.render_board()
        self.game_board.grid(row=0,
                             column=1,
                             rowspan=2,
                             sticky=N + W,
                             padx=5,
                             pady=5)

    def resize(self, new_resolution, is_new_full_screen):
        is_same_resolution = (self.width, self.height) == (new_resolution[0],
                                                           new_resolution[1])
        is_same_full_screen_setting = self.is_full_screen.get(
        ) == is_new_full_screen
        if is_same_resolution and is_same_full_screen_setting:
            return
        self.data_reader.save_settings(new_resolution[2],
                                       str(is_new_full_screen))
        player_data = []
        if self.is_game_setup_in_progress.get():
            player_data = self._save_game_setup_before_resize()
        self._process_config()
        self._remove_everything()
        self._render_panes()
        if self.is_game_setup_in_progress.get():
            self._load_game_setup_before_resize(player_data)
        self._text_placer()
        self.menu.select(self.menu.settings_tab)
        self.status_bar.log(
            '%s %i×%i' % (s.language.new_resolution, self.width, self.height))

    def _save_game_setup_before_resize(self):
        player_data = []
        for i in range(6):
            if self.game_board.player_setups[i].active.get():
                player_data.append(
                    self.game_board.player_setups[i].get_player_state())
        return player_data

    def _load_game_setup_before_resize(self, player_data):
        self.start_game_setup()
        for i, player_state in enumerate(player_data):
            self.game_board.player_setups[i].set_player_state(player_state)

    def _remove_everything(self):
        Gallery.discard_cache()
        self.menu.destroy()
        self.game_board.destroy()
        self.status_bar.destroy()
        try:
            self.ship.destroy()
        except AttributeError:
            pass

    def confirm_discard_game(self):
        is_game_in_progress = self.is_game_in_progress.get()
        if is_game_in_progress and not askokcancel(
                self.ui_text_variables['new_game'].get(),
                s.language.discard_game):
            return False
        elif is_game_in_progress:
            self.is_game_in_progress.set(0)
            return True
        else:
            return True

    def start_game_setup(self):
        confirmed = self.confirm_discard_game()
        if confirmed:
            if self.is_game_setup_in_progress.get():
                self._reset_board()
            self._prepare_game_setup()

    def _reset_board(self):
        self.is_game_setup_in_progress.set(0)
        self.game_board.destroy()
        self._render_game_board_placeholder()
        self.menu.release_new_game_button()

    def _prepare_game_setup(self):
        self.is_game_setup_in_progress.set(1)
        self.menu.push_new_game_button()
        self.game_board.destroy()
        self._render_game_board_placeholder()
        self.game_board = NewGamePanel(self)
        self.game_board.columnconfigure('all', weight=1)
        self.game_board.rowconfigure('all', weight=1)
        self.game_board.grid(row=0,
                             column=1,
                             rowspan=2,
                             sticky=N + E + W + S,
                             padx=5,
                             pady=5)

    def select_file_to_load(self):
        if self.is_game_in_progress.get():
            if not askokcancel(self.ui_text_variables['new_game'].get(),
                               s.language.discard_game_b):
                return
        game_state = self.save_handler.load_saved_state()
        if game_state is None or not game_state.check():
            return
        self.status_bar.log(s.language.loading_game)
        self.load_game(game_state)

    def load_game(self, game_state):
        self._reset_for_game_start()
        for data in game_state.player_data:
            empire_literal = game_state.player_data[data].empire
            game_state.player_data[data].empire = Empires.get_by_adjective(
                empire_literal)
            self.players[data] = Player(self.game_board,
                                        game_state.player_data[data])
        self._prepare_new_ui()
        while self.player_order[0] != game_state.next_player:
            self.player_order.append(self.player_order.pop(0))
        self.engine = Vezerlo(self, game_state.taverns)
        self.game_board.update_wind_direction(game_state.wind_index)
        if game_state.is_lieutenant_found:
            self.engine.set_hadnagyElokerult()
        if game_state.is_grog_lord_defeated:
            self.engine.set_grogbaroLegyozve()
        self.menu.update_developer_tab()
        self.engine.set_paklik(game_state.card_decks)
        self.status_bar.log(s.language.loading_done)
        self.engine.szakasz_0()

    def _reset_for_game_start(self):
        self.is_game_setup_in_progress.set(0)
        self.card_texts = self.data_reader.load_cards_text()
        self.players = {}
        self.update_idletasks()
        self.is_game_in_progress.set(1)
        self.game_board.destroy()
        self.game_board = Board(self, self.board_width)
        self.game_board.grid(row=0,
                             column=1,
                             rowspan=2,
                             sticky=N + W,
                             padx=5,
                             pady=5)

    def _prepare_new_ui(self):
        self.player_order = sorted(self.players.keys())
        self.game_board.render_board()
        self.menu.release_new_game_button()
        self.menu.select(self.menu.game_tab)

    def start_game(self, player_states):
        self._reset_for_game_start()
        for index, player_state in enumerate(player_states):
            self.players['player' + str(index)] = Player(
                self.game_board, player_state)
        self._prepare_new_ui()
        self.engine = Vezerlo(self)
        self.menu.update_developer_tab()
        self.status_bar.log(s.language.start_game_done)
        self.engine.szakasz_0()

    def _follow_game_progress_change(self, *args, **kwargs):
        if self.is_game_in_progress.get():
            self.menu.tab(1, state=NORMAL)
        else:
            self.menu.tab(1, state=DISABLED)

    def _follow_turn_progress_change(self, *args, **kwargs):
        if not self.is_turn_in_progress.get():
            self.menu.enable_save_buttons()
            self.menu.tab(0, state=NORMAL)
            self.menu.tab(2, state=NORMAL)
        else:
            self.menu.disable_save_buttons()
            self.menu.tab(0, state=DISABLED)
            self.menu.tab(2, state=DISABLED)

    def shutdown_ttk_repeat_fix(self):
        self.eval('::ttk::CancelRepeat')
        self.exit_in_progress = True
        self.exit()

    def get_window_position(self):
        info = self.winfo_geometry()
        xpos = info.index('+') + 1
        ypos = info[xpos:].index('+') + xpos
        x = int(info[xpos:ypos])
        y = int(info[ypos:])
        return x, y

    def save_game(self):
        game_state = GameState()
        game_state.next_player = self.player_order[0]
        game_state.wind_index = self.game_board.wind_direction.index(0)
        for player in sorted(list(self.players)):
            game_state.player_data[player] = self.players[player].export()
        for empire in Empires:
            game_state.taverns[empire.value.capital] = self.engine.varostar[
                empire.value.capital].export_matroz()
        game_state.card_decks = [
            self.engine.eventdeck, self.engine.eventstack,
            self.engine.kincspakli, self.engine.treasurestack
        ]
        game_state.is_grog_lord_defeated = self.engine.grogbaroLegyozve.get()
        game_state.is_lieutenant_found = self.engine.hadnagyElokerult.get()
        if game_state.check():
            self.save_handler.write_save(game_state)
        else:
            raise RuntimeError('Invalid game state.')

    def save_and_exit(self):
        self.save_game()
        self.shutdown_ttk_repeat_fix()

    def exit(self):
        if self.is_game_in_progress.get(
        ) and self.game_board.is_field_select_blinking:
            self.game_board.is_field_select_blinking = False
        self.destroy()
 def setUp(self):
     self._tabs = Tabs()
Пример #13
0
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import base
import json
import session
from pager import Pager
from editor import Editor
from basicpage import BasicPage
from tabs import Tabs
from help import Help

s = session.Session()
content = []

toptabs = Tabs()
toptabs.height = 10
toptabs.expand = False
s.addPage(toptabs)

elems = base.ElementList()

elems.add(base.Element(["locat"]))
elems.add(base.Element(["bobcat"]))
elems.add(base.Element(["locat"]))

bplist = base.ElementViewSlice(elems)
toptabs.add_tab(name="Commands", page=bplist)

tabs = Tabs()
s.addPage(tabs)