Esempio n. 1
0
    def main_window(self, *args):
        self.mainframe = Frame(self.root)
        self.mainframe.grid(column=0, row=0, sticky=E+W+N+S)
        self.bottomframe = Frame(self.root)
        self.bottomframe.grid(column=0, row=1, sticky=E+W)
        self.statusbar = Label(
            self.bottomframe, text=self._filehandler.statustext, anchor=W)
        self.statusbar.pack(fill=BOTH, padx=0, pady=0)
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=1)
        self.root.rowconfigure(1, pad=10)
        self.pw = PanedWindow(self.mainframe, orient=HORIZONTAL)
        self.pw.pack(fill=BOTH, expand=1)
        self.pane_left = Frame(self.root)
        self.pw.add(self.pane_left)
        self.pane_right = Frame(self.root)
        self.pw.add(self.pane_right)

        self.frame_left = Frame(self.pane_left)
        self.frame_left.pack(fill=BOTH, expand=1, padx=3, pady=3)
        self.frame_center = Frame(self.pane_right)
        self.frame_center.grid(row=0, column=0, sticky=W+N, rowspan=4)
        self.frame_right = Frame(self.pane_right)
        self.frame_right.grid(row=0, column=1, sticky=W+E+N+S, padx=3, pady=3)
        self.pane_right.columnconfigure(1, weight=1)
        self.pane_right.rowconfigure(0, weight=1)
        self.sf1 = Text(self.frame_left, height=1, width=25, borderwidth=1,
                        relief="solid", highlightthickness=0)
        self.sf1.insert(1.0, "TODO: Searchbar")
        self.sf1.grid(row=0, column=0, sticky=W+E+N+S, pady=5)
        self.sf1.config(state=DISABLED)
        self.cs = Button(self.frame_left, text="X", width=1)
        self.cs.grid(row=0, column=1)
        self.frame_left.columnconfigure(0, weight=1)
Esempio n. 2
0
    def __init__(self, controller):
        self.controller = controller  # function to call

        self.root = Tk()  # create main window called root
        self.root.state('zoomed')  # have root be full screen
        self.root.title('Picasa')  # name the display
        self.root.protocol(
            'WM_DELETE_WINDOW',
            lambda: self.controller('stop'))  # Trap close window

        self.menu = PicasaMenu(self.root, controller)  # create main menu
        self.root.config(menu=self.menu)  # add menu to window

        self.TAB = PanedWindow(self.root, orient=VERTICAL)  # Top And Bottom
        self.TAB.grid(sticky='nsew')
        self.LAR = PanedWindow(self.root, orient=HORIZONTAL)  # Left And Right
        self.LAR.grid(sticky='nsew')
        self.TAB.add(self.LAR)

        self.tree = Tree(self.root, controller)  # create tree
        self.LAR.add(self.tree)

        self.gallery = Gallery(self.root, controller)  # create all pics
        self.LAR.add(self.gallery)

        self.status = Status(self.TAB, controller)  # create status text
        self.TAB.add(self.status)

        self.TAB.config(sashrelief='raised')  # make sash visible
        self.LAR.config(sashrelief='raised')

        self.root.grid_columnconfigure(0, weight=1)  # make all resizeable
        self.root.grid_rowconfigure(0, weight=1)

        self.TAB.sash_place(0, 1, 1000)
Esempio n. 3
0
    def __init__(self, file=None, parent=None):
        Frame.__init__(self, parent, name="base")
        self.file = file
        self.make_menu()

        self.pw = PanedWindow(self, orient=VERTICAL)
        self.pw.pack(side=TOP, expand=YES)
        self.text = Text(self.pw)
        self.pw.add(self.text)
        self.output = Text(self.pw)
        self.pw.add(self.output)

        if self.file:
            self.master.title(self.file)
            self.settext()
        else:
            self.master.title("Untitled")
        self.text.focus()

        self.makestatus()
        self.update_status_msg("Welcome")

        self.bind_all("<Control-n>", self.new)
        self.bind_all("<Control-s>", self.save)
        self.bind_all("<Control-q>", self.quit)
        self.text.bind("<KeyPress>", self.update_pos)
Esempio n. 4
0
    def __init__(self, **kw):
        if RootView.__instance != None:
            raise Exception("Cette classe est un Singleton")
        else:
            RootView.__instance = self

        super(RootView, self).__init__(**kw)
        self.title("Chroma V0.1")
        self.frame = HomeFrame(self)
        self.frame.pack(side="top", fill="both", expand=True)
        #self.wm_attributes("-fullscreen",True)

        #button
        self.panedWindow = PanedWindow()
        self.panedWindow.pack(side="bottom")
        self.buttonStop = Button(self.panedWindow,
                                 text="Stop",
                                 command=self._generateEventStopButton)
        self.panedWindow.add(self.buttonStop)
        self.buttonOk = Button(self.panedWindow,
                               text="Ok",
                               command=self._generateEventOkButton)
        self.panedWindow.add(self.buttonOk)
        buttonPlus = Button(
            self.panedWindow,
            text="Plus",
            command=lambda: self.event_generate('<<BUTTON_PLUS>>'))
        self.panedWindow.add(buttonPlus)
        buttonMoins = Button(
            self.panedWindow,
            text="Moins",
            command=lambda: self.event_generate('<<BUTTON_MOINS>>'))
        self.panedWindow.add(buttonMoins)
Esempio n. 5
0
    def add(self, pane, **kwargs):
        Tk_PanedWindow.add(self, pane, **kwargs)

        self._list_of_panes.append(pane)
        quantity_of_panes = len(self._list_of_panes)
        if quantity_of_panes >= 2:
            handle_index = quantity_of_panes - 2
            handle = self.HANDLE_CLASS(
                self,
                handle_index,
                bg=self._color,
                height=self._height,
                width=self._width,
                cursor=self._cursor,
                disallow_dragging=self._disallow_dragging,
                on_click=self._on_click,
                image=self._image)
            if self.ORIENT == VERTICAL:
                handle.place(relx=0.5, anchor="c")
            else:
                handle.place(rely=0.5, anchor="c")
            self._handle_list.append(handle)
            callback_id1 = pane.bind("<Configure>",
                                     lambda event, handle_index=handle_index:
                                     self._on_configure_pane(handle_index),
                                     "+")
            callback_id2 = self._list_of_panes[handle_index].bind(
                "<Configure>",
                lambda event, handle_index=handle_index: self.
                _on_configure_pane(handle_index),
                "+")
            self._configure_callbacks.append((callback_id1, callback_id2))
Esempio n. 6
0
 def _update_position_all_handles(self):
     for sash_index, handle in enumerate(self._handle_list):
         if self.ORIENT == VERTICAL:
             x, y = Tk_PanedWindow.sash_coord(self, sash_index)
             handle.place(y=y)
         else:
             x, y = Tk_PanedWindow.sash_coord(self, sash_index)
             handle.place(x=x)
    def _on_drag_sash(self, event):
        coord_x = event.x
        coord_y = event.y

        Tk_PanedWindow.sash_place(self, self._active_sash, coord_x, coord_y)
        self._update_position_all_handles()

        return "break"
Esempio n. 8
0
    def __init__(self, parent):
        PanedWindow.__init__(self, parent, background="white")

        self.parent = parent
        self.init_data()
        self.init_log()
        self.init_ui()
        self.update_status()
Esempio n. 9
0
    def __init__(self):
        '''Treeview FUNCTION'''
        self.window=Tk()

        self.window.config(bg="lightcyan", highlightthickness=8, highlightbackground="navy", highlightcolor="navy")


        self.window.title("STAFF DETAILS TREE")

        self.frame1=PanedWindow(self.window)
        self.treeview = Treeview(self.frame1, columns=("Name", "Email","Mobile","Password","Type"))
        self.treeview.heading("Name", text="NAME")

        self.treeview.heading("Email", text="EMAIL")
        self.treeview.heading("Mobile", text="MOBILE")
        self.treeview.heading("Type", text="TYPE")







        # for table color


        self.treeview["show"] = "headings"

        style = Style()
        style.configure("Treeview.Heading", font=("Script MT Bold", 16))
        style.configure("Treeview", font=("calibri", 13))







        #
        # scroll=Scrollbar(self.frame1,orient="vertical",command=self.treeview.yview)
        # scroll.pack(side=RIGHT,fill=Y)
        # self.treeview.configure(yscrollcommand=scroll.set)
        self.treeview.pack()
        self.insertData()
        self.frame2=PanedWindow(self.window)
        delBtn=Button(self.frame2,text="Delete Item",command=self.delItem)
        delBtn.grid(row=0,column=0)



        self.frame1.pack()
        self.frame2.pack()


        self.window.mainloop()


#obj=staffTree()
Esempio n. 10
0
    def __init__(self):

        self.window = Tk()

        self.window.config(bg="lightcyan",
                           highlightthickness=8,
                           highlightbackground="navy",
                           highlightcolor="navy")

        self.frame1 = PanedWindow(self.window)

        self.enter = Label(self.frame1,
                           text="ENTER MENU",
                           bg="lightcyan",
                           fg="red",
                           font=("Harlow Solid Italic", 40, "italic", "bold"))

        self.menuText = Entry(self.frame1)

        self.searchbttn = Button(self.frame1,
                                 text="Search",
                                 command=self.searchfun)

        self.enter.grid(row=0, column=0)
        self.menuText.grid(row=0, column=1)
        self.searchbttn.grid(row=0, column=2)

        # ''''''''FRAME 2''''

        self.frame2 = PanedWindow(self.window)

        self.treeview = Treeview(self.frame2,
                                 columns=("menuid", "name", "description",
                                          "price"))
        self.treeview.heading("menuid", text="MENU ID")
        self.treeview.heading("name", text="NAME")
        self.treeview.heading("description", text="DESCRIPTION")
        self.treeview.heading("price", text="PRICE")

        # for table color

        style = Style()
        style.configure("Treeview.Heading", font=("Script MT Bold", 16))
        style.configure("Treeview", font=("calibri", 13))

        self.treeview["show"] = "headings"

        self.treeview.pack()

        self.frame1.pack()
        self.frame2.pack()

        self.window.mainloop()


#obj=entermenu()
Esempio n. 11
0
 def __init__(self, master, lists):
     """MultiListbox class constructor
     Args:
         master - parent view
         lists - columns
     Author: Pavel"""
     PanedWindow.__init__(self,
                          master,
                          borderwidth=1,
                          showhandle=False,
                          sashwidth=2,
                          sashpad=0,
                          relief=SUNKEN)
     self.lists = []
     self.columns = []
     for l, w in lists:
         self.columns.append(l)
         frame = Frame(self)
         frame.pack(side=LEFT, expand=YES, fill=BOTH)
         tl = Label(frame, text=l, borderwidth=2, relief=GROOVE)
         tl.pack(fill=X)
         tl.bind('<Button-1>', self.clickon)
         lb = Listbox(frame,
                      bg=ListBox_color,
                      width=w,
                      borderwidth=0,
                      selectborderwidth=0,
                      relief=FLAT,
                      exportselection=FALSE,
                      selectmode=MULTIPLE)
         lb.pack(expand=YES, fill=BOTH)
         self.lists.append(lb)
         lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y))
         lb.bind('<Button-1>', lambda e, s=self: s._select(e.y))
         lb.bind('<Leave>', lambda e: 'break')
         lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y))
         lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y))
         lb.bind('<Button-4>',
                 lambda e, s=self: s._scroll(SCROLL, 1, PAGES))
         lb.bind('<Button-5>',
                 lambda e, s=self: s._scroll(SCROLL, -1, PAGES))
         self.add(frame)
     Label(master, borderwidth=1, relief=FLAT).pack(fill=X)
     sb = Scrollbar(master,
                    orient=VERTICAL,
                    command=self._scroll,
                    borderwidth=1)
     sb.pack(fill=Y, side=RIGHT, expand=NO)
     for l in self.lists:
         l['yscrollcommand'] = sb.set
         l.bind("<MouseWheel>",
                lambda e, s=self: s._scroll(SCROLL, e.delta, UNITS))
     #self.add(frame)
     self.pack(expand=YES, fill=BOTH)
     self.sorted_by = -1
     self.previousWheel = 0
Esempio n. 12
0
def main():
    root = tk.Tk()
    #top frame configuration

    fig, ax = plt.subplots()
    xs = np.arange(-np.pi, np.pi, 0.001)
    ys = np.sin(xs)
    ax.plot(xs, ys)

    plot_window = PanedWindow(root)

    canvas = FigureCanvasTkAgg(fig, master=plot_window)
    canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)

    toolbar = NavigationToolbar2TkAgg(canvas, plot_window)
    toolbar.update()

    top_frame = Frame(root, )
    left_frame = Frame(root, relief=tk.SUNKEN, bd=4)
    bottom_frame = Frame(root)

    left_frame.pack(side=LEFT, fill=BOTH, expand=False)

    plot_window.pack(side=TOP, fill=BOTH, expand=True)
    top_frame.pack(side=TOP, fill=X, expand=False)
    bottom_frame.pack(side=TOP, fill=X, expand=False)

    Button(top_frame, text="top left button").pack(side=LEFT,
                                                   fill=X,
                                                   expand=True)
    Button(top_frame, text="top right button").pack(side=LEFT,
                                                    fill=X,
                                                    expand=True)
    #left frame configuration

    Button(left_frame, text="left button 1").pack(side=TOP,
                                                  ipady=90,
                                                  fill=X,
                                                  anchor=tk.N,
                                                  expand=True)
    Button(left_frame, text="left button 2").pack(side=TOP,
                                                  ipady=90,
                                                  fill=X,
                                                  anchor=tk.N,
                                                  expand=True)

    #right frame configuratioion

    Button(bottom_frame, text="right button 1").pack(side=TOP,
                                                     fill=BOTH,
                                                     expand=True)
    Button(bottom_frame, text="right button 2").pack(side=TOP,
                                                     fill=BOTH,
                                                     expand=True)

    root.mainloop()
Esempio n. 13
0
def main_win(i):
    i.title('Main Window')
    i.geometry('1000x500')
    p = PanedWindow(i, orient=VERTICAL, height=10, width=30, bg='green')
    p.pack(side='bottom')
    about = Text(p, height=1, width=50)
    about.pack()
    fbtn = Button(p, text="Upload A File", command=lambda: file_update(about))
    fbtn.pack(side='bottom')
    win_menu(i)
    close_btn(i)
Esempio n. 14
0
def email_gui(i):
    email_k = open_wind(i)
    panel = PanedWindow(email_k, orient=VERTICAL, height=10, width=30)
    panel.pack()
    username_bx = Text(panel, height=1, width=30)
    username_bx.pack(expand=1)
    password_bx = Text(panel, height=1, width=30)
    password_bx.pack(expand=1)
    subbtn = Button(panel,
                    text='Submit',
                    command=lambda: set_my_Email(username_bx, password_bx))
    subbtn.pack()
Esempio n. 15
0
    def ConfigComponents(self, NumberOfServices=0):

        self.lbServiceGroupName = Label(self)
        self.lbServiceGroupName["bg"] = "#616161"
        self.lbServiceGroupName["textvariable"] = self.NameGroup
        self.lbServiceGroupName["font"] = "Roboto 20"
        self.lbServiceGroupName["fg"] = "white"
        self.lbServiceGroupName.pack(pady=5)

        self.progressNumber = DoubleVar()
        self.progressBarStyle = Style()
        self.progressBarStyle.theme_use('clam')
        self.progressBarStyle.configure("Horizontal.TProgressbar",
                                        troughcolor='#616161',
                                        background="#34A853",
                                        lightcolor='#34A853',
                                        darkcolor="#34A853")
        self.progressBarProcessing = Progressbar(
            self,
            style="Horizontal.TProgressbar",
            variable=self.progressNumber,
            maximum=NumberOfServices)
        self.progressBarProcessing.pack(fill=X, padx=10, pady=10)

        self.OrganizerButtons = PanedWindow(self)
        self.OrganizerButtons["height"] = 80
        self.OrganizerButtons["bg"] = "#616161"
        self.OrganizerButtons.pack(fill=X, padx=10)

        self.btStarGroup = Button(self.OrganizerButtons,
                                  command=self.StartGroup)
        self.btStarGroup["bg"] = "#616161"
        self.btStarGroup["bd"] = 0
        self.btStarGroup["command"] = self.StartGroup
        self.imagebtStarGroup = PhotoImage(
            file=self.resource_path("btStartGroupIcon.png"))
        self.btStarGroup.config(image=self.imagebtStarGroup)
        self.btStarGroup.pack(fill=X, side=LEFT, padx=10)

        self.btStopGroup = Button(self.OrganizerButtons,
                                  command=self.StopGroup)
        self.btStopGroup["bg"] = "#616161"
        self.btStopGroup["bd"] = 0
        self.btStopGroup["command"] = self.StopGroup
        self.imagebtStopGroup = PhotoImage(
            file=self.resource_path("btStopGroupIcon.png"))
        self.btStopGroup.config(image=self.imagebtStopGroup)
        self.btStopGroup.pack(fill=X, side=LEFT, padx=5)

        self.linhaDeSeparacao = PanedWindow(self)
        self.linhaDeSeparacao["height"] = 2
        self.linhaDeSeparacao["bg"] = "#9E9E9E"
        self.linhaDeSeparacao.pack(fill=X, padx=20, pady=5)
Esempio n. 16
0
    def _init_components(self):
        self._panes = PanedWindow(self, orient='horizontal', sashrelief='raised')
        self._panes.pack(expand=True, fill='both')

        self._left_pane = Frame(self._panes, padx=2, pady=2)
        self._right_pane = Frame(self._panes)
        self._panes.add(self._left_pane, width=250)
        self._panes.add(self._right_pane)

        # group name
        group_name_pane = LabelFrame(self._left_pane, text="Group", padx=10, pady=5)
        group_name_pane.pack(fill='x')

        self._group_name = GroupNameLabel(group_name_pane, self._group)
        self._group_name.pack(expand=True, fill='both')

        # group order
        group_order_pane = LabelFrame(self._left_pane, text="Order", padx=10, pady=5)
        group_order_pane.pack(fill='x')

        self._group_order = IntegerContainer(group_order_pane, integer=self._group.order())
        self._group_order.pack(expand=True, fill='both')

        # apex
        self._apex_pane = LabelFrame(self._left_pane, text="Apex", padx=10, pady=5)
        self._apex_pane.pack(expand=True, fill='both')

        self._apex_container = ApexListContainer(self._apex_pane, apex=self._group.apex())
        self._apex_container.pack(expand=True, fill='both')

        # graph controls
        cocliques_frame = LabelFrame(self._left_pane, text="Cocliques", padx=10, pady=5)
        cocliques_frame.pack(fill='x')

        self._cocliques_button = Button(cocliques_frame, text="Calculate", command=self._show_cocliques)
        self._cocliques_button.pack(anchor='nw')

        self._cocliques_container = ListContainer(cocliques_frame)
        self._cocliques_list = Listbox(self._cocliques_container)
        self._cocliques_container.set_listbox(self._cocliques_list)

        # Button(graph_controls, text='Group equivalent vertices').pack(anchor='nw')

        # this is a button that show up instead of graph canvas if we uncheck 'Show graph' checkbox.
        self._show_graph_button = Button(self._right_pane, text='Show graph',
                                         command=self._show_graph_canvas)
        self._graph_canvas = None
        if self._show_graph:
            self._show_graph_canvas()
        else:
            self._show_graph_button.pack()
Esempio n. 17
0
 def __init__(self,
              master=None,
              title="Error",
              message="Bad User name or Password\nplease try again!",
              delai=1250,
              typ="error"):
     from tkinter import Label, Tk, PanedWindow
     from winsound import MessageBeep as snd
     lst = dict(
         (("error", 10), ("info", 60), ("warning", 23), ("message", 75)))
     if master == None:
         master = Tk()
         master.title(title)
     frm = PanedWindow(master)
     frm.pack()
     lbl = Label(frm, text=message, width=24)
     lbl.pack()
     lbl.focus()
     if master.title() == title:
         lbl.after(delai, master.destroy)
     else:
         frm.after(delai, frm.destroy)
     try:
         snd(lst[typ])
     except:
         print("the arg '", typ,
               "' must be 'error','info','warning',or 'message'")
     frm.mainloop()
Esempio n. 18
0
    def popupInformation(self, title="Info", message="Info"):
        if self.displayPopup:
            #popup
            self.popup = Tk()
            self.popup.wm_title(title)

            frame = Frame(self.popup)
            panedWindow = PanedWindow(frame)

            #icon warning
            labelIconWarning = Label(panedWindow,
                                     image="::tk::icons::information")
            panedWindow.add(labelIconWarning)

            #text
            labelMessage = Label(panedWindow, text=message, font=NORM_FONT)
            panedWindow.add(labelMessage)

            #button
            buttonOk = Button(frame, text="Ok")

            #display
            panedWindow.pack(side="top")
            buttonOk.pack(side="bottom")
            frame.pack(side="top", fill="x", padx=10, expand=True)
        else:
            self.popup.focus_force()
        self.popup.mainloop()
Esempio n. 19
0
def email_win(i):
    e = open_wind(i)
    e.title('Email Window')
    e.geometry('200x120')
    p = PanedWindow(e, orient=VERTICAL, height=50, width=30)
    p.pack()
    close_btn(e)
    emailText = Label(
        p, text='Please enter the email\nto send the selecte file to')
    emailText.pack(side='top')
    text = Text(p, height=1, width=30, bg='white', bd=2)
    text.pack(side='bottom')
    subBTN = Button(p, text='Submit', command=lambda: checkEmail(text, e))
    subBTN.pack()
 def __init__(self):
     self.root = Tk()
     self.frame = Frame()
     self.frame.pack(side='top')
     self.label = Label(self.frame, text=COMP.format(0))
     self.label2 = Label(self.frame, text="")
     self.canvas = Canvas(self.root, width=WIDTH, height=HIEGHT,
                          borderwidth=0, highlightthickness=0, bg="black")
     self.painel = PanedWindow(orient='vertical')
     self.list_of_no = []
     self.list_of_vert = []
     self.graph = []
     self.x = []
     self.y = []
     self.components = 0
    def __init__(self):

        self.window = Toplevel()

        self.window.config(bg="lightcyan",
                           highlightthickness=8,
                           highlightbackground="navy",
                           highlightcolor="navy")

        # *******************FRAME 1 Tree view***************************

        #DATA QUERY

        self.frame1 = PanedWindow(self.window)
        self.treeview = Treeview(self.frame1,
                                 columns=("menu", "name", "description",
                                          "price"))
        self.treeview.heading("menu", text="Menu Item")
        self.treeview.heading("name", text="Name")
        self.treeview.heading("description", text="Description")
        self.treeview.heading("price", text="Price")

        self.treeview["show"] = "headings"

        # for table color

        style = Style()
        style.configure("Treeview.Heading", font=("Script MT Bold", 16))
        style.configure("Treeview", font=("calibri", 13))

        self.treeview.pack()

        #*********EVENT BIND TREEVIW**************

        self.frame1.pack()
        self.showFullData()

        # ***************FRAME 2********************

        self.frame2 = PanedWindow(self.window)

        self.delBtn = Button(self.frame2,
                             text="Delete",
                             command=self.deleteCommand)
        self.delBtn.grid(row=0, column=1)

        self.frame2.pack()
        self.window.mainloop()
Esempio n. 22
0
    def LoadPainels(self):

        self.topMenu = TopMenu(self)
        self.topMenu.AdButtons()
        self.topMenu["bg"] = "#616161"
        self.topMenu.pack()

        self.linhaDeSeparacao = PanedWindow()
        self.linhaDeSeparacao["bg"] = "#9E9E9E"
        self.linhaDeSeparacao.pack()

        self.bottomPanels = BottomPanels(self)
        self.bottomPanels["bg"] = "#616161"
        self.bottomPanels.pack()

        self.configPainels()
Esempio n. 23
0
def main_win(i):
    i.title('Mass Emailer')
    p = PanedWindow(i, orient=VERTICAL, height=10, width=30)
    p.pack()
    label = Label(
        p,
        text=
        'Select a file with the clients firstname, lastname and email address')
    label.pack()
    about = Text(p, height=1, width=50)
    about.pack()
    fbtn = Button(p, text="Upload File", command=lambda: file_update(about))
    fbtn.pack(expand=1)
    emailbtn = Button(p, text='Send emails', command=lambda: read_csv(i))
    emailbtn.pack(side='bottom')
    win_menu(i)
Esempio n. 24
0
 def _on_configure_pane(self, sash_index):
     '''
     重载基类的相关方法
     :param sash_index:
     :return: None
     '''
     x, y = Tk_PanedWindow.sash_coord(self, sash_index)
     self._handle_list[sash_index].place(y=y)
Esempio n. 25
0
    def setup(self):
        logging.info("Start application")
        self.displayMenuBar()

        #Panel Choix Dossier & Liste Mp3
        self.main_pane = PanedWindow(self.root,
                                     orient=HORIZONTAL,
                                     bg=self.config["color"]["paneBackground"])
        self.main_pane.pack(side=TOP)

        self.Paned2 = PanedWindow(self.root,
                                  orient=HORIZONTAL,
                                  bg=self.config["color"]["paneBackground"])
        self.Paned2.pack()

        self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.root.mainloop()
Esempio n. 26
0
 def _update_position_all_handles(self):
     '''
     重载基类的相关方法
     :return: None
     '''
     for sash_index, handle in enumerate(self._handle_list):
         x, y = Tk_PanedWindow.sash_coord(self, sash_index)
         handle.place(y=y)
Esempio n. 27
0
 def __init__(self, master=None):
     Frame.__init__(self, master)
     self.pack(expand=1, fill='both')
     self.master.geometry('1440x900')
     paned_window = PanedWindow(self)
     self.treeview_kspelements = TreeviewKSPElements(self)
     self.treeview_kspobjects = TreeviewKSPObjects(self)
     paned_window.pack(expand=1, fill='both')
     paned_window.add(self.treeview_kspelements)
     paned_window.add(self.treeview_kspobjects)
     
     menubar = Menu(self)
     
     filemenu = Menu(self)
     filemenu.add_command(label='Open', command=self._open)
     filemenu.add_command(label='Save', command=self._save)
     filemenu.add_command(label='Save As', command=self._save_as)
     filemenu.add_separator()
     filemenu.add_command(label='Exit', command=self.master.destroy)
     menubar.add_cascade(menu=filemenu, label='File')
     
     insertmenu = Menu(self)
     insertmenu.add_command(label='KSP Element', command=self._insert_element, state='disabled')
     insertmenu.add_command(label='KSP Object', command=self._insert_object)
     menubar.add_cascade(menu=insertmenu, label='Insert')
     self.master.config(menu=menubar)
 def __init__(self):
     self.root = Tk()
     self.frame = Frame()
     self.frame.pack(side="top")
     self.title = Label(self.frame, text=TITLE)
     self.canvas = Canvas(self.root,
                          width=WIDTH,
                          height=HEIGHT,
                          borderwidth=0,
                          highlightthickness=0,
                          bg="black")
     self.painel = PanedWindow(orient="horizontal")
     self.list_money = []
     self.ents = []
     self.num_itens = 0
     self.wallet = 0
     self.loss = 0
     self.typ = ""
    def __init__(self,
                 master,
                 color="gray",
                 size=60,
                 sashpad=2,
                 disallow_dragging=False,
                 on_click=None,
                 image=None,
                 cursor=None,
                 opaqueresize=True):
        Tk_PanedWindow.__init__(self,
                                master,
                                showhandle=False,
                                orient=self.ORIENT,
                                sashpad=sashpad,
                                opaqueresize=opaqueresize)

        self._active_sash = None
        self._on_click = on_click
        self._image = image
        self._color = color
        self._cursor = cursor

        self._configure_callbacks = []

        if not opaqueresize:
            disallow_dragging = True

        self._disallow_dragging = disallow_dragging

        self._handle_list = []
        self._list_of_panes = []

        if self.ORIENT == VERTICAL:
            self._width = size
            self._height = 2 * sashpad
        else:
            self._width = 2 * sashpad
            self._height = size

        if opaqueresize:
            self.bind('<Button-1>', self._on_mark_sash)
            self.bind('<B1-Motion>', self._on_drag_sash)
            self.bind('<ButtonRelease-1>', self._on_release)
Esempio n. 30
0
    def __init__(self, tk: Tk):
        tk.title("Layered Polygons")

        menubar = Menu(tk)

        menu_file = Menu(menubar, tearoff=0)
        menu_file.add_command(label="New...", command=self._new_scene)
        menu_file.add_command(label="Open...", command=self._open_scene)
        menu_file.add_separator()
        menu_file.add_command(label="Save", command=self._save_scene)
        menu_file.add_command(label="Save As...", command=self._save_scene_as)
        menu_file.add_separator()
        menu_export = Menu(menu_file, tearoff=0)
        menu_export.add_command(label="Wavefront (.obj)...",
                                command=self._export_obj)
        menu_file.add_cascade(label="Export As", menu=menu_export)
        menu_file.add_separator()
        menu_file.add_command(label="Quit", command=self._quit_app)
        menubar.add_cascade(label="File", menu=menu_file)

        tk.config(menu=menubar)

        paned = PanedWindow(tk, relief=RAISED)
        paned.pack(fill=BOTH, expand=1)

        frame = Frame(paned)
        paned.add(frame)
        self._canvas = LayPolyCanvas(frame)
        bar_x = Scrollbar(frame, orient=HORIZONTAL)
        bar_x.pack(side=BOTTOM, fill=X)
        bar_x.config(command=self._canvas.xview)
        bar_y = Scrollbar(frame, orient=VERTICAL)
        bar_y.pack(side=RIGHT, fill=Y)
        bar_y.config(command=self._canvas.yview)
        self._canvas.config(xscrollcommand=bar_x.set, yscrollcommand=bar_y.set)
        self._canvas.pack(side=LEFT, expand=True, fill=BOTH)
        # Thanks to the two guys on Stack Overflow for that!
        # ( http://stackoverflow.com/a/7734187 )

        self._layer_list = Listbox(paned, selectmode=SINGLE)
        paned.add(self._layer_list)

        self._scene = None
        self._current_layer = None
        self._is_drawing_polygon = False
        self._tk = tk

        self._canvas.bind("<Button-1>", self._canvas_left_click)
        self._canvas.bind("<Button-3>", self._canvas_right_click)
        self._canvas.bind("<Motion>", self._canvas_mouse_moved)
        self._layer_list.bind("<<ListboxSelect>>", self._layer_change)

        self._current_path = None
Esempio n. 31
0
def main_win(i):
    i.title('Auto Mass Texter System')
    p = PanedWindow(i, orient=VERTICAL, height=10, width=30)
    p.pack()
    label = Label(
        p,
        text=
        'Select a file with the clients firstname, lastname, Phone Number and Phone provider'
    )
    label.pack()
    file_name = Text(p, height=1, width=50)
    file_name.pack()
    smsBTN = Button(i, text='Send SMS', command=lambda: readfrom_csv())
    smsBTN.pack(side='bottom')
    fbtn = Button(p,
                  text="Upload File",
                  command=lambda: file_update(file_name, smsBTN))
    fbtn.pack(expand=1)
    win_menu(i)
Esempio n. 32
0
def main():
    root=tk.Tk()
    #top frame configuration
    

    fig,ax=plt.subplots()
    xs=np.arange(-np.pi,np.pi,0.001)
    ys=np.sin(xs)
    ax.plot(xs,ys)

    plot_window=PanedWindow(root)

    canvas=FigureCanvasTkAgg(fig,master=plot_window)
    canvas.get_tk_widget().pack(side=TOP,fill=BOTH,expand=True)

    toolbar = NavigationToolbar2TkAgg(canvas, plot_window)
    toolbar.update()

    top_frame=Frame(root,)
    left_frame=Frame(root, relief=tk.SUNKEN,bd=4)
    bottom_frame=Frame(root)

    left_frame.pack(side=LEFT,fill=BOTH,expand=False)
    
    plot_window.pack(side=TOP,fill=BOTH,expand=True)
    top_frame.pack(side=TOP,fill=X,expand=False)
    bottom_frame.pack(side=TOP,fill=X,expand=False)

    Button(top_frame,text="top left button").pack(side=LEFT, fill=X, expand=True)
    Button(top_frame,text="top right button").pack(side=LEFT,fill=X,expand=True)
    #left frame configuration

    Button(left_frame,text="left button 1").pack(side=TOP,ipady=90,fill=X,anchor=tk.N, expand=True)
    Button(left_frame,text="left button 2").pack(side=TOP,ipady=90,fill=X,anchor=tk.N, expand=True)

    #right frame configuratioion

    Button(bottom_frame,text="right button 1").pack(side=TOP, fill=BOTH, expand=True)
    Button(bottom_frame,text="right button 2").pack(side=TOP, fill=BOTH, expand=True)    


    root.mainloop()
Esempio n. 33
0
    def _init_components(self):
        self._panes = PanedWindow(self,
                                  orient='horizontal',
                                  sashrelief="raised")
        self._panes.pack(expand=True, fill='both')

        self._left_pane = Frame(self._panes, padx=10, pady=5)
        self._right_pane = PanedWindow(self._panes)
        self._panes.add(self._left_pane, sticky='n')
        self._panes.add(self._right_pane)

        self._group_select = GroupSelect(self._left_pane)
        self._group_select.pack(expand=True, fill='x')

        # spacer
        Frame(self._left_pane, height=10).pack()

        graph_controls = LabelFrame(self._left_pane,
                                    text="Graph options",
                                    padx=10,
                                    pady=5)
        graph_controls.columnconfigure(1, weight=1)
        graph_controls.pack(expand=True, fill='x')

        self._show_graph_checkbutton = CheckBox(graph_controls,
                                                text='Show graph')
        self._show_graph_checkbutton.select()
        self._show_graph_checkbutton.grid(row=0, columnspan=2, sticky='w')

        Label(graph_controls, text='Algorithm').grid(row=1, sticky='w')
        self._graph_type = OptionList(graph_controls,
                                      values=tuple(
                                          MainWindow.GRAPH_TYPES.keys()))
        self._graph_type.config(width=15)
        self._graph_type.grid(row=1, column=1, sticky='we')

        # spacer
        Frame(self._left_pane, height=10).pack()

        self._go_button = Button(self._left_pane, text='Go', command=self._go)
        self._go_button.pack()
Esempio n. 34
0
    def __init__(self, tk: Tk):
        tk.title("Layered Polygons")

        menubar = Menu(tk)

        menu_file = Menu(menubar, tearoff=0)
        menu_file.add_command(label="New...", command=self._new_scene)
        menu_file.add_command(label="Open...", command=self._open_scene)
        menu_file.add_separator()
        menu_file.add_command(label="Save", command=self._save_scene)
        menu_file.add_command(label="Save As...", command=self._save_scene_as)
        menu_file.add_separator()
        menu_export = Menu(menu_file, tearoff=0)
        menu_export.add_command(label="Wavefront (.obj)...",
                                command=self._export_obj)
        menu_file.add_cascade(label="Export As", menu=menu_export)
        menu_file.add_separator()
        menu_file.add_command(label="Quit", command=self._quit_app)
        menubar.add_cascade(label="File", menu=menu_file)

        tk.config(menu=menubar)

        paned = PanedWindow(tk, relief=RAISED)
        paned.pack(fill=BOTH, expand=1)

        frame = Frame(paned)
        paned.add(frame)
        self._canvas = LayPolyCanvas(frame)
        bar_x = Scrollbar(frame, orient=HORIZONTAL)
        bar_x.pack(side=BOTTOM, fill=X)
        bar_x.config(command=self._canvas.xview)
        bar_y = Scrollbar(frame, orient=VERTICAL)
        bar_y.pack(side=RIGHT, fill=Y)
        bar_y.config(command=self._canvas.yview)
        self._canvas.config(xscrollcommand=bar_x.set, yscrollcommand=bar_y.set)
        self._canvas.pack(side=LEFT, expand=True, fill=BOTH)
        # Thanks to the two guys on Stack Overflow for that!
        # ( http://stackoverflow.com/a/7734187 )

        self._layer_list = Listbox(paned, selectmode=SINGLE)
        paned.add(self._layer_list)

        self._scene = None
        self._current_layer = None
        self._is_drawing_polygon = False
        self._tk = tk

        self._canvas.bind("<Button-1>", self._canvas_left_click)
        self._canvas.bind("<Button-3>", self._canvas_right_click)
        self._canvas.bind("<Motion>", self._canvas_mouse_moved)
        self._layer_list.bind("<<ListboxSelect>>", self._layer_change)

        self._current_path = None
Esempio n. 35
0
class DatabaseView:
    def __init__(self, root, config_save, rest_client_factory):
        self.config = config_save.get_configuration()
        self.root = root
        application_folder = BrowserConfiguration.get_application_directory_and_create_if_necessary()
        self.database = XnatDatabase(rest_client_factory.create_rest_client(self.config), self.config, application_folder)
        self.database_models = XnatModelFactory(self.database)
        self.config_save = config_save

        self.master_paned_window = PanedWindow(root)
        self.master_paned_window.pack(fill=BOTH, expand=1)

        self._project_listbox = LabeledListBox(self.master_paned_window, self.database_models.project_list_model, 'Project:')
        self.master_paned_window.add(self._project_listbox)

        self._subject_listbox = LabeledListBox(self.master_paned_window, self.database_models.subject_list_model, 'Subject:')
        self.master_paned_window.add(self._subject_listbox)

        self._scan_listbox = LabeledProgressListBox(self.master_paned_window, self.database_models.scan_list_model, "Scans:")
        self.master_paned_window.add(self._scan_listbox)

    def close(self):
        self.master_paned_window.destroy()
Esempio n. 36
0
 def initWidget(self,fenetre) :
     #print "init"
     self.card_win = PanedWindow(fenetre, orient=VERTICAL)
     fenetre.child=self
     self.refreshWidget()
Esempio n. 37
0
class NetGame(Game) :
    def __init__(self) :
        Game.__init__(self)
        import socket
        import tkinter
        self.local = self.host=socket.gethostbyname(socket.gethostname()) # Get local machine ip
        from tkinter import Tk,PanedWindow,StringVar,Entry,Button,VERTICAL,HORIZONTAL,Label
        fenetre=Tk()
        fenetre.title('Socket parameters') 
        self.netgame_win = PanedWindow(fenetre, orient=VERTICAL)
        host_zone=PanedWindow(self.netgame_win, orient=HORIZONTAL)
        host=StringVar()
        host.set(self.local)
        def modifHost(*args) :
            self.host=host.get()
            if self.local==self.host :
                start_button.config(text="Create")
            else :
                start_button.config(text="Join")
        host.trace("w", modifHost)
        host_wid=Entry(host_zone, width=30,textvariable=host)
        host_wid.pack()
        host_label=Label(fenetre, text="Host (you are "+self.local+") :")
        host_zone.add(host_label)
        host_zone.add(host_wid)
        self.netgame_win.add(host_zone)
        port_zone=PanedWindow(self.netgame_win, orient=HORIZONTAL)
        port=StringVar()
        self.port=52333
        port.set(str(self.port))
        # adress_wid=Label(None, textvariable=self.cost, background='red',width=5, anchor=W)
        def modifPort(*args) :
            #print "modify port to",port.get()
            try :
                self.port=int(port.get())
            except :
                port.set("")
        port.trace("w", modifPort)
        port_wid=Entry(fenetre, width=30,textvariable=port)
        #port_wid.grid(column=0, row=1)
        host_wid.focus() 
        port_wid.pack()
        port_label=Label(fenetre, text="Port :")
        port_zone.add(port_label)
        port_zone.add(port_wid)
        self.netgame_win.add(port_zone)
        #Create the open button
        def start() :
            fenetre.destroy()
        start_button=Button(self.netgame_win,text="Create",command=start)
        self.netgame_win.add(start_button)
        self.netgame_win.pack()
        #fenetre.focus_set()
        #start_button.focus()        
        fenetre.mainloop()
             # Import socket module
        self.soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    # Reserve a port for your service.
        if self.local==self.host :
            self.soc.bind((self.host, self.port))        # Bind to the port
            print( "socket listening")
            self.soc.listen(5)                 # Now wait for client connection.

            self.soc, addr = self.soc.accept()     # Establish connection with client.
            print( 'Got connection from', addr)
            #self.soc.send('Thank you for connecting')
            #c.close()                # Close the connection
            self.firstplayer=choice([1,2])
            print( "FIRST PLAYER IS",self.firstplayer)
            self.soc.send(str(3-self.firstplayer).encode('utf-8'))
        else :
            self.soc.connect((self.host, self.port))
            print( "connect ok")
            p=self.soc.recv(1024).decode('utf-8')
            try :
                self.firstplayer=int(p)
            except :
                print( "error concerning first player, got ",p)
        self.remains=""
            #self.soc.close()                     # Close the socket when done
    def initialize(self) :
        if self.firstplayer==1 : # player1 doit etre le local
            print( "first player is local")
            self.player1.sendDeck()
            self.player2.receiveDeck()
        else :
            print( "first player is hosted")
            self.player2.receiveDeck()
            self.player1.sendDeck()         
        Game.initialize(self)
        if self.player==self.player2 :
            self.endturn_button.update(self.player)
    def send(self,str):
        print("send :"+str)
        self.soc.send(str.encode('utf-8'))
    def random(self,n,intrange) :
        if self.local==self.host :
            jet=sample(list(range(intrange)),n)
            print( "send",jet)
            self.soc.send((" ".join(map(str,jet))+"\n" ).encode('utf-8'))
        else :
            print( "waiting ",n," random number in range",intrange)
            if self.remains  :
                p=self.remains
                self.remains=""
            else :
                p=self.soc.recv(1024).decode('utf-8')
                print( "recv ",p)
            p=p.strip()
            if "\n" in p :
                self.remains,p = p.split("\n",1)
            jet=list(map(int,p.strip().split()))
            print( "got",jet)
        return jet
Esempio n. 38
0
    def buildFrame(self):
        """Contruct frame widgets and initialize data."""
        if self.built:
            return

        # Ensure all required parts of the conflict model are properly set-up.
        self.conflict.reorderOptionsByDM()
        self.conflict.options.set_indexes()
        self.conflict.infeasibles.validate()
        self.conflict.recalculateFeasibleStates()
        self.conflict.coalitions.validate()

        for dm in self.conflict.decisionMakers:
            dm.calculatePerceived()
            dm.calculatePreferences()

        self.lastBuildConflict = self.conflict.export_rep()

        # Define variables that will display in the infoFrame
        self.infoText = StringVar(value='')

        # Define frame-specific variables
        self.sol = LogicalSolver(self.conflict)
        self.sol.findEquilibria()

        # infoFrame: frame and label definitions (with master 'self.infoFrame')
        self.infoLabel = ttk.Label(self.infoFrame, textvariable=self.infoText)

        # helpFrame: frame and label definitions (with master 'self.helpFrame')
        self.helpLabel = ttk.Label(self.helpFrame, textvariable=self.helpVar,
                                   wraplength=150)

        # Define frame-specific input widgets (with 'self' as master)
        self.paneMaster = PanedWindow(self, orient=HORIZONTAL, sashwidth=10,
                                      sashrelief="raised", sashpad=3,
                                      relief="sunken")

        self.pane1 = ttk.Frame(self.paneMaster)
        self.coalitionSelector = CoalitionSelector(self.pane1, self.conflict,
                                                   self)
        self.solutionTable = OptionFormSolutionTable(self.pane1, self.conflict,
                                                     self)
        self.exporter = Exporter(self.pane1, self.conflict, self)

        self.pane2 = ttk.Frame(self.paneMaster)
        self.narrator = LogNarrator(self.pane2, self.conflict, self)

        # ########  preliminary gridding and option configuration

        # configuring the input frame
        self.grid(column=0, row=0, rowspan=5, sticky=NSEW)
        self.grid_remove()
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        # configuring infoFrame & infoFrame widgets
        self.infoFrame.grid(column=2, row=0, sticky=NSEW, padx=3, pady=3)
        self.infoFrame.grid_remove()
        self.infoLabel.grid(column=0, row=1, sticky=NSEW)

        # configuring helpFrame & helpFrame widgets
        self.helpFrame.grid(column=2, row=1, sticky=NSEW, padx=3, pady=3)
        self.helpFrame.grid_remove()
        self.helpLabel.grid(column=0, row=0, sticky=NSEW)

        # configuring frame-specific options
        self.paneMaster.grid(column=0, row=1, sticky=NSEW)
        self.paneMaster.add(self.pane1, width=600, stretch='always')
        self.pane1.rowconfigure(1, weight=1)
        self.pane1.columnconfigure(0, weight=1)
        self.coalitionSelector.grid(row=0, column=0, sticky=NSEW)
        self.solutionTable.grid(row=1, column=0, sticky=NSEW)
        self.exporter.grid(row=2, column=0, sticky=NSEW)

        self.paneMaster.add(self.pane2, width=250, stretch='always')
        self.pane2.rowconfigure(0, weight=1)
        self.pane2.columnconfigure(0, weight=1)
        self.narrator.grid(row=0, column=0, sticky=NSEW)

        # bindings
        self.coalitionSelector.bind("<<CoalitionsChanged>>",
                                    self.refresh)

        self.built = True
class PreferencesFrame(FrameTemplate):
    """Used to set decision maker's preferences for use in prioritization."""

    # Label used for button to select frame in the main program.
    buttonLabel = 'Prioritization'
    # Image used on button to select frame, when frame is active.
    activeIcon = 'icons/Prioritization_ON.gif'
    # Image used on button to select frame, when frame is inactive.
    inactiveIcon = 'icons/Prioritization_OFF.gif'
    # Help text to be displayed when screen is active.
    helpText = ("Select a decision maker from the column at left by clicking "
                "its 'Edit' button.  Enter preferred conditions using the "
                "inputs to the right.  Preferred conditions for the selected "
                "decision maker are shown at the far right, from most "
                "important at the top, to least important at the bottom.")

# ########################     INITIALIZATION  ################################
    def __init__(self, master, conflict, *args):
        """Initialize the Frame. Does not build widgets."""
        FrameTemplate.__init__(self, master, conflict, self.buttonLabel,
                               self.activeIcon, self.inactiveIcon,
                               self.helpText)

        self.lastBuildDMs = None
        self.lastBuildOptions = None
        self.lastBuildInfeasibles = None
        self.lastBuildRanking = None


# ############################     METHODS  ###################################

    def hasRequiredData(self):
        """Check that minimum data required to render the frame exists."""
        if len(self.conflict.decisionMakers) < 1:
            return False
        if len(self.conflict.options) < 1:
            return False
        if len(self.conflict.feasibles) < 1:
            self.conflict.recalculateFeasibleStates()
            if len(self.conflict.feasibles) < 1:
                return False
        else:
            return True

    def dataChanged(self):
        """Check if data has changed since the last build of the Frame."""
        if self.lastBuildDMs != self.conflict.decisionMakers.export_rep():
            return True
        if self.lastBuildOptions != self.conflict.options.export_rep():
            return True
        if self.lastBuildInfeasibles != self.conflict.infeasibles.export_rep():
            return True
        if self.lastBuildRanking != self.conflict.useManualPreferenceRanking:
            return True
        else:
            return False

    def buildFrame(self):
        """Contruct frame widgets and initialize data."""
        if self.built:
            return

        # Ensure all required parts of the conflict model are properly set-up.
        self.conflict.reorderOptionsByDM()
        self.conflict.options.set_indexes()
        self.conflict.infeasibles.validate()
        self.conflict.recalculateFeasibleStates()

        for dm in self.conflict.decisionMakers:
            dm.calculatePerceived()
            dm.calculatePreferences()

        self.lastBuildDMs = self.conflict.decisionMakers.export_rep()
        self.lastBuildOptions = self.conflict.options.export_rep()
        self.lastBuildInfeasibles = self.conflict.infeasibles.export_rep()
        self.lastBuildRanking = self.conflict.useManualPreferenceRanking

        # Define variables that will display in the infoFrame
        numD = len(self.conflict.decisionMakers)
        self.infoText = StringVar(
            value='Valid Preferences set for {0}/{0} DMs.'.format(numD))

        # Define frame-specific variables
        self.dm = None

        # infoFrame: frame and label definitions (with master 'self.infoFrame')
        self.infoLabel = ttk.Label(self.infoFrame, textvariable=self.infoText)

        # helpFrame: frame and label definitions (with master 'self.helpFrame')
        self.helpLabel = ttk.Label(self.helpFrame, textvariable=self.helpVar,
                                   wraplength=150)

        # Define frame-specific input widgets (with 'self' as master)
        self.paneMaster = PanedWindow(self, orient=VERTICAL, sashwidth=5,
                                      sashrelief="raised", sashpad=2,
                                      relief="sunken")

        self.paneTop = ttk.Frame(self.paneMaster)
        self.rankings = PreferenceRankingMaster(self.paneTop, self.conflict)
        self.editor = RadiobuttonEntry(self.paneTop, self.conflict)
        self.paneTopRightMaster = PanedWindow(self.paneTop, orient=HORIZONTAL,
                                              sashwidth=5, sashrelief="raised",
                                              sashpad=2, relief="sunken")
        self.staging = PreferenceStaging(self.paneTopRightMaster,
                                         self.conflict)
        self.preferenceDisp = PreferenceListDisplay(self.paneTopRightMaster,
                                                    self.conflict)

        self.paneBottom = ttk.Frame(self.paneMaster)
        self.optionTable = OptionFormTable(self.paneBottom, self.conflict)

        self.usePrioritizationButton = ttk.Button(
            self,
            text=("Use preference prioritization. Any manually set "
                  "preference rankings will be lost."),
            command=self.usePrioritization)

        # ########  preliminary gridding and option configuration

        # configuring the input frame
        self.grid(column=0, row=0, rowspan=5, sticky=NSEW)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)
        self.grid_remove()

        # configuring infoFrame & infoFrame widgets
        self.infoFrame.grid(column=2, row=0, sticky=NSEW, padx=3, pady=3)
        self.infoFrame.grid_remove()
        self.infoLabel.grid(column=0, row=1, sticky=NSEW)

        # configuring helpFrame & helpFrame widgets
        self.helpFrame.grid(column=2, row=1, sticky=NSEW, padx=3, pady=3)
        self.helpFrame.grid_remove()
        self.helpLabel.grid(column=0, row=0, sticky=NSEW)

        # configuring frame-specific options
        self.paneMaster.grid(column=0, row=1, sticky=NSEW)
        self.paneMaster.add(self.paneTop, minsize=200)
        self.rankings.grid(column=0, row=1, sticky=NSEW)
        ttk.Separator(self.paneTop, orient=VERTICAL).grid(
            column=1, row=1, sticky=NSEW, padx=3)
        self.editor.grid(column=2, row=1, sticky=NSEW)
        ttk.Separator(self.paneTop, orient=VERTICAL).grid(
            column=3, row=1, sticky=NSEW, padx=3)
        self.paneTopRightMaster.grid(column=4, row=1, sticky=NSEW)
        self.paneTop.columnconfigure(0, weight=0)
        self.paneTop.columnconfigure(2, weight=0)
        self.paneTop.columnconfigure(4, weight=1)
        self.paneTop.rowconfigure(1, weight=1)

        self.usePrioritizationButton.grid(column=0, row=0, columnspan=5,
                                          sticky=NSEW)

        self.paneTopRightMaster.add(self.staging)
        self.paneTopRightMaster.add(self.preferenceDisp)

        self.paneMaster.add(self.paneBottom)
        self.optionTable.grid(column=0, row=0, sticky=NSEW)
        self.paneBottom.columnconfigure(0, weight=1)
        self.paneBottom.rowconfigure(0, weight=1)

        # bindings
        self.rankings.bind('<<DMchg>>', self.dmChgHandler)
        self.editor.bind('<<AddPref>>', self.addPref)
        self.editor.bind('<<StagePref>>', self.stagePref)
        self.staging.bind('<<SelCond>>', self.selCondChg)
        self.staging.bind('<<PullFromStage>>', self.pullFromStage)
        self.preferenceDisp.bind('<<SelPref>>', self.selPrefChg)
        self.preferenceDisp.bind('<<ValueChange>>', self.refresh)

        self.dmChgHandler()

        self.built = True

    def enter(self, *args):
        """Re-grid the screen into the master. Perform required updates."""
        if self.dataChanged():
            self.clearFrame()

        FrameTemplate.enter(self)

    def refresh(self, *args):
        """Refresh data in all active display widgets."""
        for dm in self.conflict.decisionMakers:
            dm.calculatePreferences()
        self.editor.reloadOpts()
        self.rankings.refresh()
        self.preferenceDisp.refresh()
        self.optionTable.buildTable(self.dm)

        self.checkIfUsingRankings()

    def checkIfUsingRankings(self, event=None):
        """Disable screen if Manual Ranking has been assigned."""
        if self.conflict.useManualPreferenceRanking:
            self.usePrioritizationButton.grid()
            self.rankings.disable()
            self.editor.disable()
            self.staging.disable()
            self.preferenceDisp.disable()
        else:
            self.usePrioritizationButton.grid_remove()

    def usePrioritization(self):
        """Reactivate the screen if user decides to use prioritization."""
        self.conflict.useManualPreferenceRanking = False
        self.conflict.preferenceErrors = None
        self.refresh()

    def dmChgHandler(self, event=None):
        """Bound to <<DMchg>>."""
        self.dm = self.rankings.dm
        self.preferenceDisp.changeDM(self.dm)
        self.optionTable.buildTable(self.dm)
        self.staging.clear()
        self.editor.setStates('clear')
        if self.dm is None:
            self.preferenceDisp.disable()
            self.editor.disable()
            self.staging.disable()
        else:
            self.preferenceDisp.enable()
            self.editor.enable()

    def addPref(self, event=None):
        """Add a preference for the active decision maker."""
        pref = self.editor.getStates()
        self.dm.preferences.append(pref)
        self.refresh()

    def stagePref(self, event=None):
        """Send a condition to the staging area."""
        if self.editor.hasValidIf:
            for cond in self.editor.ifCond:
                self.staging.addCondition(cond)
        else:
            condData = self.editor.getStates()
            newCond = self.conflict.newCondition(condData)
            self.staging.addCondition(newCond)

        self.editor.setStates('clear')

    def pullFromStage(self, event=None):
        """Move a compound condition from Staging to Preferences."""
        newPref = self.staging.conditionList
        self.staging.clear()
        self.dm.preferences.append(newPref)
        self.refresh()

    def selCondChg(self, event=None):
        """Triggered when a condition is selected in staging."""
        condition = self.staging.conditionList[event.x]
        self.editor.setStates(condition.ynd())

    def selPrefChg(self, event=None):
        """Triggered when a preference is select from preferences."""
        condition = self.dm.preferences[event.x]
        self.staging.setList(condition)
Esempio n. 40
0
    def __init__(self) :
        Game.__init__(self)
        import socket
        import tkinter
        self.local = self.host=socket.gethostbyname(socket.gethostname()) # Get local machine ip
        from tkinter import Tk,PanedWindow,StringVar,Entry,Button,VERTICAL,HORIZONTAL,Label
        fenetre=Tk()
        fenetre.title('Socket parameters') 
        self.netgame_win = PanedWindow(fenetre, orient=VERTICAL)
        host_zone=PanedWindow(self.netgame_win, orient=HORIZONTAL)
        host=StringVar()
        host.set(self.local)
        def modifHost(*args) :
            self.host=host.get()
            if self.local==self.host :
                start_button.config(text="Create")
            else :
                start_button.config(text="Join")
        host.trace("w", modifHost)
        host_wid=Entry(host_zone, width=30,textvariable=host)
        host_wid.pack()
        host_label=Label(fenetre, text="Host (you are "+self.local+") :")
        host_zone.add(host_label)
        host_zone.add(host_wid)
        self.netgame_win.add(host_zone)
        port_zone=PanedWindow(self.netgame_win, orient=HORIZONTAL)
        port=StringVar()
        self.port=52333
        port.set(str(self.port))
        # adress_wid=Label(None, textvariable=self.cost, background='red',width=5, anchor=W)
        def modifPort(*args) :
            #print "modify port to",port.get()
            try :
                self.port=int(port.get())
            except :
                port.set("")
        port.trace("w", modifPort)
        port_wid=Entry(fenetre, width=30,textvariable=port)
        #port_wid.grid(column=0, row=1)
        host_wid.focus() 
        port_wid.pack()
        port_label=Label(fenetre, text="Port :")
        port_zone.add(port_label)
        port_zone.add(port_wid)
        self.netgame_win.add(port_zone)
        #Create the open button
        def start() :
            fenetre.destroy()
        start_button=Button(self.netgame_win,text="Create",command=start)
        self.netgame_win.add(start_button)
        self.netgame_win.pack()
        #fenetre.focus_set()
        #start_button.focus()        
        fenetre.mainloop()
             # Import socket module
        self.soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    # Reserve a port for your service.
        if self.local==self.host :
            self.soc.bind((self.host, self.port))        # Bind to the port
            print( "socket listening")
            self.soc.listen(5)                 # Now wait for client connection.

            self.soc, addr = self.soc.accept()     # Establish connection with client.
            print( 'Got connection from', addr)
            #self.soc.send('Thank you for connecting')
            #c.close()                # Close the connection
            self.firstplayer=choice([1,2])
            print( "FIRST PLAYER IS",self.firstplayer)
            self.soc.send(str(3-self.firstplayer).encode('utf-8'))
        else :
            self.soc.connect((self.host, self.port))
            print( "connect ok")
            p=self.soc.recv(1024).decode('utf-8')
            try :
                self.firstplayer=int(p)
            except :
                print( "error concerning first player, got ",p)
        self.remains=""
Esempio n. 41
0
class StabilityFrame(FrameTemplate):
    """Frame used to for Stability Analysis."""

    # Label used for button to select frame in the main program.
    buttonLabel = 'Post Analysis'
    # Image used on button to select frame, when frame is active.
    activeIcon = 'icons/Post_Analysis_ON.gif'
    # Image used on button to select frame, when frame is inactive.
    inactiveIcon = 'icons/Post_Analysis_OFF.gif'
    # Help text to be displayed when screen is active.
    helpText = ("Selecting coalitions, status quo and goals at the top left"
                "will generate a reachability tree below the status quo, and "
                "detail the patterns that preferences must match for the goal "
                "state to be reached.")

# ########################     INITIALIZATION  ################################
    def __init__(self, master, conflict, *args):
        """Initialize the Frame. Does not build widgets."""
        FrameTemplate.__init__(self, master, conflict, self.buttonLabel,
                               self.activeIcon, self.inactiveIcon,
                               self.helpText)

        self.lastBuildConflict = None


# ############################     METHODS  ###################################

    def hasRequiredData(self):
        """Check that minimum data required to render the frame exists."""
        if len(self.conflict.decisionMakers) < 1:
            return False
        if len(self.conflict.options) < 1:
            return False
        if len(self.conflict.feasibles) < 1:
            return False
        if self.conflict.preferenceErrors:
            return False
        else:
            return True

    def dataChanged(self):
        """Check if data has changed since the last build of the Frame."""
        if self.lastBuildConflict != self.conflict.export_rep():
            return True
        else:
            return False

    def buildFrame(self):
        """Contruct frame widgets and initialize data."""
        if self.built:
            return

        # Ensure all required parts of the conflict model are properly set-up.
        self.conflict.reorderOptionsByDM()
        self.conflict.options.set_indexes()
        self.conflict.infeasibles.validate()
        self.conflict.recalculateFeasibleStates()

        for dm in self.conflict.decisionMakers:
            dm.calculatePerceived()
            dm.calculatePreferences()

        self.lastBuildConflict = self.conflict.export_rep()

        # Define frame-specific variables
        self.sol = GoalSeeker(self.conflict)

        # infoFrame: frame and label definitions (with master 'self.infoFrame')
        self.infoLabel = ttk.Label(self.infoFrame, text="")

        # helpFrame: frame and label definitions (with master 'self.helpFrame')
        self.helpLabel = ttk.Label(self.helpFrame, textvariable=self.helpVar,
                                   wraplength=150)

        # Define frame-specific input widgets (with 'self' as master)
        self.paneMaster = PanedWindow(self, orient=HORIZONTAL, sashwidth=10,
                                      sashrelief="raised", sashpad=3,
                                      relief="sunken")

        self.paneLeft = PanedWindow(self.paneMaster, orient=VERTICAL,
                                    sashwidth=10, sashrelief="raised",
                                    sashpad=3, relief="sunken")

        self.paneLeftTop = ttk.Frame(self.paneLeft)
        self.coalitionSelector = CoalitionSelector(self.paneLeftTop,
                                                   self.conflict, self)
        self.statusQuoAndGoals = StatusQuoAndGoals(self.paneLeftTop,
                                                   self.conflict)
        self.reachableTree = ReachableTreeViewer(self.paneLeftTop,
                                                 self.conflict, self)

        self.paneLeftBottom = ttk.Frame(self.paneLeft)
        self.optionFormTable = OptionFormTable(self.paneLeftBottom,
                                               self.conflict)

        self.paneRight = ttk.Frame(self.paneMaster)
        self.patternNarrator = PatternNarrator(self.paneRight, self.conflict,
                                               self)

        # ########  preliminary gridding and option configuration

        # configuring the input frame
        self.grid(column=0, row=0, rowspan=5, sticky=NSEW)
        self.grid_remove()
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # configuring infoFrame & infoFrame widgets
        self.infoFrame.grid(column=2, row=0, sticky=NSEW, padx=3, pady=3)
        self.infoFrame.grid_remove()
        self.infoLabel.grid(column=0, row=1, sticky=NSEW)

        # configuring helpFrame & helpFrame widgets
        self.helpFrame.grid(column=2, row=1, sticky=NSEW, padx=3, pady=3)
        self.helpFrame.grid_remove()
        self.helpLabel.grid(column=0, row=0, sticky=NSEW)

        # configuring frame-specific options
        self.paneMaster.grid(row=0, column=0, sticky=NSEW)

        self.paneMaster.add(self.paneLeft)

        self.paneLeft.add(self.paneLeftTop)
        self.paneLeftTop.columnconfigure(1, weight=1)
        self.paneLeftTop.rowconfigure(2, weight=1)
        self.coalitionSelector.grid(row=0, column=0, sticky=NSEW)
        ttk.Separator(self, orient=HORIZONTAL).grid(row=1, column=0,
                                                    sticky=NSEW, pady=3)
        self.statusQuoAndGoals.grid(row=2, column=0, sticky=NSEW)
        self.reachableTree.grid(row=0, column=1, rowspan=3, sticky=NSEW)

        self.paneLeft.add(self.paneLeftBottom)
        self.paneLeftBottom.rowconfigure(0, weight=1)
        self.paneLeftBottom.columnconfigure(0, weight=1)
        self.optionFormTable.grid(row=0, column=0, sticky=NSEW)

        self.paneMaster.add(self.paneRight)
        self.paneRight.rowconfigure(0, weight=1)
        self.paneRight.columnconfigure(0, weight=1)
        self.patternNarrator.grid(row=0, column=0, sticky=NSEW)

        # bindings
        self.statusQuoAndGoals.bind("<<StatusQuoChanged>>",
                                    self.refresh)
        self.statusQuoAndGoals.bind("<<GoalChanged>>",
                                    self.refresh)
        self.coalitionSelector.bind("<<CoalitionsChanged>>",
                                    self.refresh)

        self.built = True

    def refresh(self, *args):
        """Refresh data in all active display widgets."""
        sq = self.statusQuoAndGoals.statusQuoSelector.current()
        goals = self.statusQuoAndGoals.getGoals()
        if len(goals) > 0:
            self.sol = GoalSeeker(self.conflict, goals)
        else:
            self.sol = GoalSeeker(self.conflict)
        self.reachableTree.buildTree(sq, watchFor=[x[0] for x in goals])
        self.patternNarrator.updateNarration(
            goalInfo=self.reachableTree.goalInfo())
    def buildFrame(self):
        """Contruct frame widgets and initialize data."""
        if self.built:
            return

        # Ensure all required parts of the conflict model are properly set-up.
        self.conflict.reorderOptionsByDM()
        self.conflict.options.set_indexes()
        self.conflict.infeasibles.validate()
        self.conflict.recalculateFeasibleStates()

        for dm in self.conflict.decisionMakers:
            dm.calculatePerceived()
            dm.calculatePreferences()

        self.lastBuildDMs = self.conflict.decisionMakers.export_rep()
        self.lastBuildOptions = self.conflict.options.export_rep()
        self.lastBuildInfeasibles = self.conflict.infeasibles.export_rep()
        self.lastBuildRanking = self.conflict.useManualPreferenceRanking

        # Define variables that will display in the infoFrame
        numD = len(self.conflict.decisionMakers)
        self.infoText = StringVar(
            value='Valid Preferences set for {0}/{0} DMs.'.format(numD))

        # Define frame-specific variables
        self.dm = None

        # infoFrame: frame and label definitions (with master 'self.infoFrame')
        self.infoLabel = ttk.Label(self.infoFrame, textvariable=self.infoText)

        # helpFrame: frame and label definitions (with master 'self.helpFrame')
        self.helpLabel = ttk.Label(self.helpFrame, textvariable=self.helpVar,
                                   wraplength=150)

        # Define frame-specific input widgets (with 'self' as master)
        self.paneMaster = PanedWindow(self, orient=VERTICAL, sashwidth=5,
                                      sashrelief="raised", sashpad=2,
                                      relief="sunken")

        self.paneTop = ttk.Frame(self.paneMaster)
        self.rankings = PreferenceRankingMaster(self.paneTop, self.conflict)
        self.editor = RadiobuttonEntry(self.paneTop, self.conflict)
        self.paneTopRightMaster = PanedWindow(self.paneTop, orient=HORIZONTAL,
                                              sashwidth=5, sashrelief="raised",
                                              sashpad=2, relief="sunken")
        self.staging = PreferenceStaging(self.paneTopRightMaster,
                                         self.conflict)
        self.preferenceDisp = PreferenceListDisplay(self.paneTopRightMaster,
                                                    self.conflict)

        self.paneBottom = ttk.Frame(self.paneMaster)
        self.optionTable = OptionFormTable(self.paneBottom, self.conflict)

        self.usePrioritizationButton = ttk.Button(
            self,
            text=("Use preference prioritization. Any manually set "
                  "preference rankings will be lost."),
            command=self.usePrioritization)

        # ########  preliminary gridding and option configuration

        # configuring the input frame
        self.grid(column=0, row=0, rowspan=5, sticky=NSEW)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)
        self.grid_remove()

        # configuring infoFrame & infoFrame widgets
        self.infoFrame.grid(column=2, row=0, sticky=NSEW, padx=3, pady=3)
        self.infoFrame.grid_remove()
        self.infoLabel.grid(column=0, row=1, sticky=NSEW)

        # configuring helpFrame & helpFrame widgets
        self.helpFrame.grid(column=2, row=1, sticky=NSEW, padx=3, pady=3)
        self.helpFrame.grid_remove()
        self.helpLabel.grid(column=0, row=0, sticky=NSEW)

        # configuring frame-specific options
        self.paneMaster.grid(column=0, row=1, sticky=NSEW)
        self.paneMaster.add(self.paneTop, minsize=200)
        self.rankings.grid(column=0, row=1, sticky=NSEW)
        ttk.Separator(self.paneTop, orient=VERTICAL).grid(
            column=1, row=1, sticky=NSEW, padx=3)
        self.editor.grid(column=2, row=1, sticky=NSEW)
        ttk.Separator(self.paneTop, orient=VERTICAL).grid(
            column=3, row=1, sticky=NSEW, padx=3)
        self.paneTopRightMaster.grid(column=4, row=1, sticky=NSEW)
        self.paneTop.columnconfigure(0, weight=0)
        self.paneTop.columnconfigure(2, weight=0)
        self.paneTop.columnconfigure(4, weight=1)
        self.paneTop.rowconfigure(1, weight=1)

        self.usePrioritizationButton.grid(column=0, row=0, columnspan=5,
                                          sticky=NSEW)

        self.paneTopRightMaster.add(self.staging)
        self.paneTopRightMaster.add(self.preferenceDisp)

        self.paneMaster.add(self.paneBottom)
        self.optionTable.grid(column=0, row=0, sticky=NSEW)
        self.paneBottom.columnconfigure(0, weight=1)
        self.paneBottom.rowconfigure(0, weight=1)

        # bindings
        self.rankings.bind('<<DMchg>>', self.dmChgHandler)
        self.editor.bind('<<AddPref>>', self.addPref)
        self.editor.bind('<<StagePref>>', self.stagePref)
        self.staging.bind('<<SelCond>>', self.selCondChg)
        self.staging.bind('<<PullFromStage>>', self.pullFromStage)
        self.preferenceDisp.bind('<<SelPref>>', self.selPrefChg)
        self.preferenceDisp.bind('<<ValueChange>>', self.refresh)

        self.dmChgHandler()

        self.built = True
Esempio n. 43
0
    def buildFrame(self):
        """Contruct frame widgets and initialize data."""
        if self.built:
            return

        # Ensure all required parts of the conflict model are properly set-up.
        self.conflict.reorderOptionsByDM()
        self.conflict.options.set_indexes()
        self.conflict.infeasibles.validate()
        self.conflict.recalculateFeasibleStates()

        for dm in self.conflict.decisionMakers:
            dm.calculatePerceived()
            dm.calculatePreferences()

        self.lastBuildConflict = self.conflict.export_rep()

        # Define frame-specific variables
        self.sol = GoalSeeker(self.conflict)

        # infoFrame: frame and label definitions (with master 'self.infoFrame')
        self.infoLabel = ttk.Label(self.infoFrame, text="")

        # helpFrame: frame and label definitions (with master 'self.helpFrame')
        self.helpLabel = ttk.Label(self.helpFrame, textvariable=self.helpVar,
                                   wraplength=150)

        # Define frame-specific input widgets (with 'self' as master)
        self.paneMaster = PanedWindow(self, orient=HORIZONTAL, sashwidth=10,
                                      sashrelief="raised", sashpad=3,
                                      relief="sunken")

        self.paneLeft = PanedWindow(self.paneMaster, orient=VERTICAL,
                                    sashwidth=10, sashrelief="raised",
                                    sashpad=3, relief="sunken")

        self.paneLeftTop = ttk.Frame(self.paneLeft)
        self.coalitionSelector = CoalitionSelector(self.paneLeftTop,
                                                   self.conflict, self)
        self.statusQuoAndGoals = StatusQuoAndGoals(self.paneLeftTop,
                                                   self.conflict)
        self.reachableTree = ReachableTreeViewer(self.paneLeftTop,
                                                 self.conflict, self)

        self.paneLeftBottom = ttk.Frame(self.paneLeft)
        self.optionFormTable = OptionFormTable(self.paneLeftBottom,
                                               self.conflict)

        self.paneRight = ttk.Frame(self.paneMaster)
        self.patternNarrator = PatternNarrator(self.paneRight, self.conflict,
                                               self)

        # ########  preliminary gridding and option configuration

        # configuring the input frame
        self.grid(column=0, row=0, rowspan=5, sticky=NSEW)
        self.grid_remove()
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # configuring infoFrame & infoFrame widgets
        self.infoFrame.grid(column=2, row=0, sticky=NSEW, padx=3, pady=3)
        self.infoFrame.grid_remove()
        self.infoLabel.grid(column=0, row=1, sticky=NSEW)

        # configuring helpFrame & helpFrame widgets
        self.helpFrame.grid(column=2, row=1, sticky=NSEW, padx=3, pady=3)
        self.helpFrame.grid_remove()
        self.helpLabel.grid(column=0, row=0, sticky=NSEW)

        # configuring frame-specific options
        self.paneMaster.grid(row=0, column=0, sticky=NSEW)

        self.paneMaster.add(self.paneLeft)

        self.paneLeft.add(self.paneLeftTop)
        self.paneLeftTop.columnconfigure(1, weight=1)
        self.paneLeftTop.rowconfigure(2, weight=1)
        self.coalitionSelector.grid(row=0, column=0, sticky=NSEW)
        ttk.Separator(self, orient=HORIZONTAL).grid(row=1, column=0,
                                                    sticky=NSEW, pady=3)
        self.statusQuoAndGoals.grid(row=2, column=0, sticky=NSEW)
        self.reachableTree.grid(row=0, column=1, rowspan=3, sticky=NSEW)

        self.paneLeft.add(self.paneLeftBottom)
        self.paneLeftBottom.rowconfigure(0, weight=1)
        self.paneLeftBottom.columnconfigure(0, weight=1)
        self.optionFormTable.grid(row=0, column=0, sticky=NSEW)

        self.paneMaster.add(self.paneRight)
        self.paneRight.rowconfigure(0, weight=1)
        self.paneRight.columnconfigure(0, weight=1)
        self.patternNarrator.grid(row=0, column=0, sticky=NSEW)

        # bindings
        self.statusQuoAndGoals.bind("<<StatusQuoChanged>>",
                                    self.refresh)
        self.statusQuoAndGoals.bind("<<GoalChanged>>",
                                    self.refresh)
        self.coalitionSelector.bind("<<CoalitionsChanged>>",
                                    self.refresh)

        self.built = True
Esempio n. 44
0
class Card :
    def __init__(self,name="Nom monstre",att=1,pv=1,bonus=None,photo='',monster_type="unknown") :
        self.name=name
        self.att = att
        self.pv = pv
        if not bonus :
            bonus=[] # a cause du fonctionnement etrange de python pour les valeurs d arguments [] par defaut
        self.bonus=bonus
        self.is_spell=(pv<1)
        self.photofile=photo
        self.dumping_file = os.path.join("CardFiles",monster_type+"_monsters.sav")
        self.monster_type = monster_type
        #global all_monsters
        name=self.name.replace(" ","_")
        self.content=self
#        try :
#            self.image = image.load(os.path.join("Card",name+".png"))
#        except :
#            self.image=None
    def equivalentto(self,other) :
        return self==other
    def show(self) :
        pass
    def constructor(self) :
        return ('Card("'+self.name+'",'+str(self.att)+","+str(self.pv)+
            ",["+",".join([p.constructor() for p in self.bonus])+"],"+
             repr(self.photofile)+",'"+self.monster_type+"')")
    def takePlace(self,*ar1,**ars) :
        pass
    def addBonus(self,bonus) :
        self.bonus.append(bonus)
    def getCost(self) :
        if self.pv > 0 :
            cost=self.att/2.+self.pv/2.+sum([p.getCost(self) for p in self.bonus])
        else :
            #print self.bonus
            #if self.bonus :
            #print self.bonus[0].getCost
            #print self.bonus[0].getCost()           
            #if len(self.bonus)>1 : print "** anomalie **"
            S = 0
            for p in self.bonus:
                if p.is_cost_alterator:
                    S += p.getCost(self)
                else:
                    S += p.getCost()
            cost=S# +0.5*(len(self.bonus)-1): why?
        if cost < 0:            cost = 0
        if hasattr(self,"cost") and self.cost!=None :
            # pour les monstres du save, l attribut cost est None        
            print ("cout=",cost," so ",int(floor(cost)))
            self.cost.set(int(floor(cost)))
            self.getStars()
        return cost
    def getStars(self):
        stars = sum([p.getStars() for p in self.bonus])
        if stars>2 : stars=(stars-1)*2
        if stars<0 : stars=0
        if hasattr(self,"stars")  and self.stars != None :
            # pour les monstres du save, l attribut stars existe = None
            self.stars.set('* '*stars)
        #print "stars=",stars
        return stars
    def getDescription(self):
        for b in reversed(self.bonus) :
            try :
                b.getDescription()
            except Exception :
                self.bonus.remove(b)
        return self.name +" ("+str(self.att)+"  "+str(self.pv)+'\n'*bool(self.bonus)+'\n'.join(
            [b.getDescription() for b in self.bonus]) +" )"
    def getInlineDescription(self):
        for b in reversed(self.bonus) :
            try :
                b.getInlineDescription()
            except Exception :
                self.bonus.remove(b)
        return self.name +" ("+str(self.att)+"  "+str(self.pv)+' '.join(
            [b.getInlineDescription() for b in self.bonus]) +" )"
    def postAndSave(self,*args):
        if self.name=="nom monstre" or self.name=="change name" or self.name in Card.blocked_creature :
            self.name="change name"
            self.refreshWidget()
            return
        if not self.verifyBonus() :
            return            
        self.deleteCreature(self.name)
        temp=self.category.get()
        pygame.init()
        fenetre=self.card_win.master
        self.card_win.pack_forget()
        self.save(None)
        

        done=False
        while not done :
            for event in pygame.event.get() :
                if event.type == pygame.QUIT :
                    done=True
        pygame.display.quit()
        self = Card("nom monstre",1,1)
        #card.pack_forget()
        self.initWidget(fenetre)
        self.category.set(temp)
        self.setFile("dummy_arg")

    def verifyBonus(self) :
        nb=[b.__class__.__name__ for b in self.bonus]
        if len(set(nb))!=len(nb) :
            showinfo("Not Allowed","You can't have twice the same bonus")
            return False
        for b1,b2 in [("Insaisissable","Provocation"),("Insaisissable","Inciblable"),("Errant","Incarnation"),
                      ("Camouflage","Provocation"),("Camouflage","ChaqueTour"),("NePeutPasAttaquer","ALaPlaceDeLAttaque"),
                      ("NePeutPasAttaquer","NePeutPasAttaquerLesHeros"),("NePeutPasAttaquerLesHeros","ALaPlaceDeLAttaque"),
                    ("GardienDeVie","QuandIlEstBlesse"),("Charge","NePeutPasRisposter"),("Furie","ALaPlaceDeLAttaque"),
                    ("NePeutPasRiposter","NePeutPasAttaquer"),("NePeutPasRiposter","CoutReduit"),("CriDeGuerre","Incarnation"),
                    ("Charge","CriDeGuerrre"),("Insaisissable","InsensibleALaMagie"),("Charge","Errant"),("CriDeGuerre","Errant"),
                    ("Errant","RaleDAgonie"),("AttaqueADistance","AvecAttaque"),("Errant","AuDebutDuProchainTour"),
                    ("BonusParEnnemi","Determine"),("QuandIlEstBlesse","Incassable"),("Souffrant","QuandIlEstBlesse") ] :
            if b1 in nb and b2 in nb :
                showinfo("Not Allowed","You can't have this combination of powers: {0} and {1}".format(b1,b2))
                return False
        total=self.constructor()
        if "QuandUnAllieEstTue" in nb and (("Spell.Invocation" in total) or ("CopieMain"  in total) or ("PlaceCarteDansMain" in total)):
            showinfo("Not Allowed","You can't have anything to do with Invocation or card creation if you have QuandUnAllieEstTue")
            return False
        return True
 
    def save(self,*args):
        if (self.name in Card.blocked_creature) :
            return
        for b in self.bonus : # on veut que la plainte maudite soit en dernier
            if b.__class__.__name__=="PlainteMaudite" :
                self.bonus.remove(b)
                self.bonus.append(b)
                break
        image = self.createImage()
        
        print ("apres createImage")
        name=self.name.replace(" ","_")
        pygame.image.save(image,"Cards/"+name+".png")
        print ("save image done")
        # now new monster
        loaded_monsters=readMonsters(self.dumping_file)
        #print "Monsters from file = ",file_monsters
        #remove_widget(self)
        loaded_monsters[self.name] = self
        #print "Monsters from file (after) = ",file_monsters
        global all_monsters
        all_monsters.update(loaded_monsters)
        #print "window reinit done"
        with open(self.dumping_file,"wb") as savefile :      
            savefile.write(bytes("\n".join([m.constructor() for k,m in sorted(loaded_monsters.items())]),'UTF-8'))
#        with open(self.dumping_file+".old","rb") as filepickle :
#            print "now in file", self.dumping_file,":",pickle.load(filepickle).keys()
#            filepickle.close()
        with open(os.path.join("CardFiles","all_monsters.sav"), "wb" ) as f :
            f.write(bytes("\n".join([m.constructor() for m in all_monsters.values()]),'UTF-8'))
        recupfile=os.path.join("CardFiles","recup_monsters.sav")
        if (not os.path.isfile(recupfile)) or len(all_monsters)>=len(open(recupfile,'r').readlines()):
            with open(recupfile, "wb" ) as f :
                f.write(bytes("\n".join([m.constructor() for k,m in sorted(all_monsters.items())]),'UTF-8'))
            print ("SAVED in all_monsters.sav and recup_monsters.sav")
        else:
            print ("WARNING : Recup monster file bigger than all monsters file")

    def initWidget(self,fenetre) :
        #print "init"
        self.card_win = PanedWindow(fenetre, orient=VERTICAL)
        fenetre.child=self
        self.refreshWidget()
    def Open(self,*args) :
        print ("open monster ",  self.opening.get())
        #deck_with_card =  self.deck_check(self.opening.get())
        creature = Card.monster_list[self.opening.get()]
        if not ( creature.name in Card.blocked_creature) :
            self.card_win.pack_forget()
            fenetre=self.card_win.master
            #for i in Card.monster_list.keys() :
            #    print i, Card.monster_list[i].getInlineDescription()
            self = Card.monster_list[self.opening.get()]
            print (self.name +" loaded")
            if self.pv<1 :
                self.is_spell=True
            else :
                self.is_spell=False
            #self.card_win.pack_forget()
            for b in self.bonus:
                b.parent = self.bonus
                b.card = self
            self.initWidget(fenetre)
        else:
            showinfo("Sorry","You can't open this monsters because he comes from the campaign.")
         
    def clicDelete(self,*args) :
        #self.card_win.pack_forget()
        #fenetre=self.card_win.master
        """
        for i in all_monsters.keys() :
            print i, all_monsters[i].getInlineDescription()
            
        """
        
        creature= self.delete.get()
        if creature in Card.blocked_creature :
            print ("not possible : creature in campaign")
            self.delete.set('delete')
            return
        if askyesno('Beware!', 'Confirm the deletion of '+creature+"?"):                
            self.deleteCreature(creature)
        self.card_win.pack_forget()
        #self.initWidget(fenetre)
        self.setFile(*args)
    

    def deleteCreature(self,creature) :
        dm=None
        global all_monsters
        if not creature in all_monsters :
            print (creature," is not in all_monsters")
            try :
                fm=os.path.join("CardFiles",self.category.get()+"_monsters.sav")
                dm = readMonsters(fm)
            except:
                print ("error reading file ",fm)
        else :
            print ("delete monster ",  creature)
            try :
                fm = os.path.join("CardFiles",(all_monsters[creature].monster_type)+"_monsters.sav")
                dm = readMonsters(fm)
            except:
                print ("ERROR : no type for ",creature, " or read error")
            del all_monsters[creature]
            fall=os.path.join("CardFiles","all_monsters.sav") 
            with open(fall,"wb") as savefile :
                savefile.write(bytes("\n".join([m.constructor() for m in all_monsters.values()]), 'UTF-8'))            
            print ("deletion of monster ",  creature, "done")
            shutil.copyfile(fall,"CardFiles/recup_monsters.sav")
        if dm and creature in dm :
            del dm[creature]
            with open(fm,"wb") as savefile :
                print('dmv',dm.values())
                savefile.write(bytes("\n".join([m.constructor() for m in dm.values()]), 'UTF-8'))
            print ("deletion of monster ",  creature, " in ",fm," done" )
        else :
            print (creature," not found in dedicated file")
            
            
        
    def choosePhoto(self,*args) :
        from tkinter.filedialog import askopenfilename
        #Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
        filename = askopenfilename(defaultextension=".gif",filetypes=[ ("image",("*.jpg", "*.gif","*.png")),('PNG file','*.png'),('Jpg file','*.jpg'),('GIF file','*.gif')]) # show an "Open" dialog box and return the path to the selected file
        if filename:
            import os.path
            chem=os.path.dirname(os.path.realpath(__file__)).replace('\\','/')+'/'
            #print chem
            if chem in filename :
                filename=filename.replace(chem,'')
                print ("filename modif",filename)
            try :
                pilImage = Image.open(filename)
                PhotoImage(pilImage,master=None)
                #ImageTk.PhotoImage(monimage)
                self.photofile=filename
                print ("photo choosen !")
            except Exception :
                print ("echec ouverture image")
                raise
        self.refreshWidget()

    def setFile(self,*args):
        self.dumping_file = os.path.join("CardFiles",self.category.get()+"_monsters.sav")
        print ("Change dumping file to ",self.dumping_file)
        self.monster_type = self.category.get()
        Card.monster_list=readMonsters(self.dumping_file)
        #from cardPowers import *
        self.refreshWidget()

    def refreshWidget(self) :
        #print "refresh"
        self.card_win.pack_forget()
        import unicodedata
        #Card window      
        self.card_win = PanedWindow(self.card_win.master, orient=VERTICAL)
        self.card_win.pack(side=TOP, expand=True, fill=BOTH, pady=2, padx=2)
        
        
        #Create the name zone
        name_zone=PanedWindow(self.card_win, orient=HORIZONTAL)
        name = StringVar() 
        name.set(self.name)
        def modifName(*args) :
            try :
                assert('"' not in name.get())
                name.get().encode('ascii')
            except Exception as e:
                print ("error on name")
                name.set(self.name)
                return
            old = self.name in Card.blocked_creature
            self.name=name.get()
            if old or self.name in Card.blocked_creature :
                self.refreshWidget()
        name.trace("w", modifName)
        name_wid=Entry(name_zone, width=30,textvariable=name)
        name_wid.pack()
        name_zone.add(name_wid)
        #Create the cost ad star stringvar
        #print int(floor(self.getCost()))
        self.cost=StringVar()
        self.stars=StringVar()
        cost_wid=Label(None, textvariable=self.cost, background='red',width=5, anchor=W)
        star_wid=Label(None, textvariable=self.stars, background='blue', anchor=E)
        self.cost.set(str(int(floor(self.getCost()))))
        self.stars.set("*"*self.getStars())
        #Add them in name zone
        name_zone.add(cost_wid)
        name_zone.add(star_wid)
        
        
        #Create an Image Zone
        image_zone=Button(self.card_win,  command=self.choosePhoto)
        if hasattr(self,"photofile") and self.photofile :            
            print ("Image: ",self.photofile)
            try :
                pilImage=Image.open(self.photofile)
                img=PhotoImage(pilImage,master=image_zone)
            except :
               decomp=self.photofile.split('/')
               for i in range(1,6) :
                   try :
                       fname="/".join(decomp[-i:])
                       print ("try to open",fname)
                       pilImage = Image.open(fname)
                       img=PhotoImage(pilImage,master=image_zone)
                       self.photofile=fname
                       break
                   except :
                       self.photofile=None
        if self.photofile :
            w, h = img.width(), img.height()
            print('wh',w,h)
            if h>400 :
                print("reduction")
                img=PhotoImage(pilImage.resize((w//2,h//2), Image.ANTIALIAS),master=image_zone)
            image_zone=Button(self.card_win,image=img,  command=self.choosePhoto)
            image_zone.image=img
            #image_zone.configure(image=image_zone.image,width=50,height=50,compound=RIGHT)
            #image_zone.pack()
            #print "IMAGE CHANGED"
        else :
            from os import path
            fname=self.name.replace(" ","_")
            if path.isfile("Cards/"+fname+".png") :
                image_zone.config(text='image can be taken from\n'+"Cards/"+fname+".png",background='white',anchor=CENTER)
            else :
                image_zone.config(text='clic to choose image',background='white',anchor=CENTER)

        #image_zone.pack()
        
        
        # POWER ZONE
        power_zone=PanedWindow(self.card_win, orient=VERTICAL)
        #fenetre=self.card_win.master
        def removePowerCreator(px) :
            def removePower(*args) :
                #print 'avant',list_pow
                self.bonus.remove(px)
                #print 'apres',list_pow
                #self.card_win.pack_forget()
                self.refreshWidget()
            return removePower
        for p in self.bonus :
            powline =  PanedWindow(self.card_win, orient=HORIZONTAL)
            pow_wid=p.initWidget(powline)
            powline.add(pow_wid)
            removepow=Button(powline, text="X", command=removePowerCreator(p), anchor=E)
            removepow.pack()
            powline.add(removepow)
            power_zone.add(powline) 
        def addPower(*args) :
            if addBonus.get()!= "add bonus":
                name=addBonus.get()
            else:
                name=add_cost_alteration.get()
            print ("added :",name)
            import CardPowers
            self.bonus+=[eval('CardPowers.'+name+'()')]
            self.bonus[-1].parent=self.bonus
            self.bonus[-1].card=self
            #self.card_win.pack_forget()
            self.refreshWidget()
        #Add bonus Option menu
        addBonus = StringVar(power_zone)
        addBonus.set("add bonus") # default value
        if not self.pv:  
            addBonus_wid = Spell.getSpellMenu(power_zone, addBonus)
        else: addBonus_wid = getBonusMenu(power_zone, addBonus) 
        addBonus.trace('w', addPower)
        if self.pv>0 or len(self.bonus)==0 or all([b.is_cost_alterator for b in self.bonus]):
            addBonus_wid.pack()
            #Add this to power zone
            power_zone.add(addBonus_wid)
        
        #Create save zone
        save_zone = PanedWindow(self.card_win, orient=HORIZONTAL)
        if self.monster_type != "all" and not(self.name in Card.blocked_creature) :
            save_wid = Button(save_zone, text="Save", command=self.postAndSave)
        elif self.monster_type != "all" : 
            save_wid = Button(save_zone, text="creature in campaign", command=None)
        else:
            save_wid = Button(save_zone, text="nead type", command=None)
        save_wid.pack()
        #Create the open button
        save_zone.pack()        
        if Card.monster_list.keys():
            self.opening = StringVar(save_zone)
            self.opening.set("Open")
            choice = [na for na in Card.monster_list.keys() if na not in Card.blocked_creature]
            choice.sort()
            #print all_monsters.keys()
            open_wid = OptionMenu(save_zone, self.opening,*choice)
            self.opening.trace('w', self.Open)
            open_wid.pack()
            save_zone.add(open_wid)
        
        if Card.monster_list.keys():
            self.delete = StringVar(save_zone)
            self.delete.set("Delete")
            choice = [na for na in Card.monster_list.keys() if na not in Card.blocked_creature]
            choice.sort()
            delete_wid = OptionMenu(save_zone, self.delete,*choice)
            self.delete.trace('w', self.clicDelete)
            delete_wid.pack()
            save_zone.add(delete_wid)
        
        #Create the type button
        self.category = StringVar(save_zone)
        self.category.set(self.monster_type)
        choice = [file2name(t,"_monsters.sav") for t in glob.glob("CardFiles/*_monsters.sav")]
        if "recup" in choice:
            choice.remove("recup")
        #print all_monsters.keys()
        category_wid = OptionMenu(save_zone, self.category,*choice)
        self.category.trace('w', self.setFile)
        
        
        
        category_wid.pack()
        
        #Add it to save zone
        save_zone.add(save_wid)
        save_zone.add(category_wid)
        
        #Create a new Strength zone for att and pv
        strength_zone=PanedWindow(self.card_win, orient=HORIZONTAL)
        att=StringVar()
        att.set(str(self.att))
        pv=StringVar() ; pv.set(str(self.pv))
        def modifiedAttPv(*args) :
            print ("modifiedAttPv")
            self.pv=int(pv.get())
            if self.pv<1 and self.is_spell==False :
                if len(self.bonus)==0 :
                    self.is_spell=True
                    self.refreshWidget()
                else :
                    self.pv=1
                    self.refreshWidget()
            if self.pv>0 and self.is_spell==True :
                if len(self.bonus)==0 :
                    self.is_spell=False
                    self.refreshWidget()
                else :
                    self.pv=0
                    self.refreshWidget()            
            self.att=int(att.get())
            self.getCost()
        att_wid = Spinbox(strength_zone, from_=0, to=1000,textvariable=att,command=modifiedAttPv)
        att_wid.pack()
        strength_zone.add(att_wid)
        strength_zone.add(Label(strength_zone, text='       ', background='white', 
             anchor=CENTER))
        pv_wid = Spinbox(strength_zone, from_=0, to=1000,textvariable=pv,command=modifiedAttPv)
        pv_wid.pack()
        strength_zone.add(pv_wid)
        
        #Put it all in window
        self.card_win.add(name_zone)
        self.card_win.add(image_zone)
        self.card_win.add(power_zone)  
        self.card_win.add(strength_zone)
        self.card_win.add(save_zone)
        
        
        self.card_win.pack()                      

    def createImage(self,black=False):
        width=189*2; height=277*2
        screen = pygame.display.set_mode((width,height))

        print ("Type = ",self.monster_type)
        if self.monster_type in all_backgrounds.keys():
            try:
                bg = pygame.image.load(all_backgrounds[self.monster_type])
            except:
                print ("error (? when load of bg")
        else:
            bg = pygame.image.load('gameAnimationImages/Card_face_avant.gif')
        #fond = PhotoImage(file =bg,master=fenetre) pilImage = Image.open(
        #ligne1 = canvas.create_line(75, 0, 75, 120)
        #ligne2 = canvas.create_line(0, 60, 150, 60)      
        if self.photofile and not black:
            try :
               img=pygame.image.load(self.photofile)
            except :
               decomp=self.photofile.split('/')
               for i in range(1,6) :
                   try :
                       fname="/".join(decomp[-i:])
                       print ("try to open",fname)
                       img=pygame.image.load(fname)
                       self.photofile=fname
                       break
                   except:
                       pass
            img = pygame.image.load(self.photofile)
            w, h = img.get_size()
            factor=max(150.*2./w,90.*2./h)
            img=pygame.transform.scale(img,(int(w*factor),int(h*factor)))
            #fenetre.photo=PhotoImage(file=self.photofile,master=canvas)
            #img=ImageTk.PhotoImage(img,master=fenetre)
            screen.blit(img,(width/2.-w*factor/2.,140.-h*factor/4.))
        else :
            try :
                name=self.name.replace(" ","_")
                img=pygame.image.load("Cards/"+name+".png")
                print ("* Found for image ","Cards/"+name+".png")
                screen.blit(img,(0,0))
            except :
                pass
        screen.blit(bg,(0,0))    
        
        pygame.font.init()
        #print  pygame.font.get_fonts()
        if self.monster_type in white_font_types:
            color = (255,255,255)
        else:
            color = (0,0,0)
        centerText(screen,(width/2.+10.,33.*2.),self.name,36-(len(self.name)>11)*(len(self.name)-11)//3,color)
        #txt = canvas.create_text(101, 32, text=self.name, font=("Calibri",12-(len(self.name)>11)*(len(self.name)-11)/5,"bold"), anchor=CENTER)
        if not(self.is_spell):
            centerText(screen,(24*2.,258*2.),str(self.att),40,color)
            centerText(screen,(169*2.,255*2.),str(self.pv),40,color)
        else :
            centerText(screen,(width/2.,265*2.),"SPELL",30,color)
        #elif self.is_spell:
        #    txt = canvas.create_text(100,265, text="SPELL", anchor=CENTER, font=("Calibri",14,'bold'))
        #txt = canvas.create_text(22,35, text=int(floor(self.getCost())), anchor=CENTER, font=("Calibri",18,'bold'))
        centerText(screen,(22*2.,35*2.),str(int(floor(self.getCost()))),50,color)
        #txt1 = canvas.create_text(92,257, text='*'*self.getStars(), anchor=CENTER, font=("Calibri",26,'bold'))
        centerText(screen,(92*2.,257*2.),'*'*self.getStars(),60,color)
        if not(self.monster_type == "unknown"):
            if self.monster_type in all_type_colors:
                Color = all_type_colors[self.monster_type]
            else:
                Color = "human"
        else:
            Color = "human"
        centerText(screen,(95*2.,142*2.),self.monster_type.capitalize(),26,Color)
        
        if len(self.bonus)>0 :
            powers = "e%96".join([b.getDescription() for b in self.bonus if b.getDescription()])
            powers = [p.split("\n") for p in powers.split("e%96")]
            print ("powers are ",powers)
        else :
            powers =""
        #print "POWERS = ", powers
        if powers: 
            space=min([80., 160./sum([len(p)*3+2 for p in powers])])
            print ("Space: ",space)
        line = 0
        for i,b in enumerate(powers):
            if b!=[''] :
                print ("power",b)
                size = min([36.,500./max([len(p) for p in b]) * 2.])
                for x,part in enumerate(b):
                    centerText(screen,(90*2.,167*2.+line*space),part,int(size),color)
                    line += 3
                line += 2
        #canvas.pack()
        #print "toto!"
        pygame.display.flip()
        return screen
      
    def init_as_invocation(self,master,spells=False):
        # monster widget in invocation widget        
        #print "monster init_as_invocation"
        self.content=StringVar()
        self.content.set(self.name)
        self.content.trace("w", self.is_changed_as_invocation)
        l = [ m for m in Card.monster_list.keys() if (spells or all_monsters[m].pv>0) and not(m in Card.blocked_creature) 
                  and (spells or not "PlainteMaudite" in all_monsters[m].constructor())
                   and not any([b.__class__.__name__=="Charge" for b in all_monsters[m].bonus])
                   and not any([b.__class__.__name__=="Errant" for b in all_monsters[m].bonus])
                   and not any([b.__class__.__name__=="Essentiel" for b in all_monsters[m].bonus])
                   and not any([b.__class__.__name__=="Incarnation" for b in all_monsters[m].bonus])
                   #and not any([b.__class__.__name__=="AuDebutDuProchainTour" for b in all_monsters[m].bonus])
                   ]
        self.widget=OptionMenu(master,self.content,*l)
        return self.widget
 
    def init_as_card(self,master):
        # monster widget in invocation widget        
        #print "monster init_as_invocation"
        self.content=StringVar()
        self.content.set(self.name)
        self.content.trace("w", self.is_changed_as_invocation)
        l = [ m for m in Card.monster_list.keys() if  not(m in Card.blocked_creature)  ]
        self.widget=OptionMenu(master,self.content,*l)
        return self.widget
 
       
    def is_changed_as_invocation(self,*args):
        print ("monster is_changed_as_invocation")
        if self.content.get()!= "Troll gris":
            new= Card.monster_list[self.content.get()]
        else:
            new = Card("Troll gris",4,4)

        #print self.content.get()
        if self.parent :
            #parent.spell=new
            #print "self.parent = True"
            self.parent.monster=new
            new.parent = self.parent
            new.card=self.card
        else :
            raise "ce cas existe ?! me dire comment"
            self.bonus[self.bonus.index(self)]=new
        #self.card_win.pack_forget()
        self.card.refreshWidget()
Esempio n. 45
0
    def refreshWidget(self) :
        #print "refresh"
        self.card_win.pack_forget()
        import unicodedata
        #Card window      
        self.card_win = PanedWindow(self.card_win.master, orient=VERTICAL)
        self.card_win.pack(side=TOP, expand=True, fill=BOTH, pady=2, padx=2)
        
        
        #Create the name zone
        name_zone=PanedWindow(self.card_win, orient=HORIZONTAL)
        name = StringVar() 
        name.set(self.name)
        def modifName(*args) :
            try :
                assert('"' not in name.get())
                name.get().encode('ascii')
            except Exception as e:
                print ("error on name")
                name.set(self.name)
                return
            old = self.name in Card.blocked_creature
            self.name=name.get()
            if old or self.name in Card.blocked_creature :
                self.refreshWidget()
        name.trace("w", modifName)
        name_wid=Entry(name_zone, width=30,textvariable=name)
        name_wid.pack()
        name_zone.add(name_wid)
        #Create the cost ad star stringvar
        #print int(floor(self.getCost()))
        self.cost=StringVar()
        self.stars=StringVar()
        cost_wid=Label(None, textvariable=self.cost, background='red',width=5, anchor=W)
        star_wid=Label(None, textvariable=self.stars, background='blue', anchor=E)
        self.cost.set(str(int(floor(self.getCost()))))
        self.stars.set("*"*self.getStars())
        #Add them in name zone
        name_zone.add(cost_wid)
        name_zone.add(star_wid)
        
        
        #Create an Image Zone
        image_zone=Button(self.card_win,  command=self.choosePhoto)
        if hasattr(self,"photofile") and self.photofile :            
            print ("Image: ",self.photofile)
            try :
                pilImage=Image.open(self.photofile)
                img=PhotoImage(pilImage,master=image_zone)
            except :
               decomp=self.photofile.split('/')
               for i in range(1,6) :
                   try :
                       fname="/".join(decomp[-i:])
                       print ("try to open",fname)
                       pilImage = Image.open(fname)
                       img=PhotoImage(pilImage,master=image_zone)
                       self.photofile=fname
                       break
                   except :
                       self.photofile=None
        if self.photofile :
            w, h = img.width(), img.height()
            print('wh',w,h)
            if h>400 :
                print("reduction")
                img=PhotoImage(pilImage.resize((w//2,h//2), Image.ANTIALIAS),master=image_zone)
            image_zone=Button(self.card_win,image=img,  command=self.choosePhoto)
            image_zone.image=img
            #image_zone.configure(image=image_zone.image,width=50,height=50,compound=RIGHT)
            #image_zone.pack()
            #print "IMAGE CHANGED"
        else :
            from os import path
            fname=self.name.replace(" ","_")
            if path.isfile("Cards/"+fname+".png") :
                image_zone.config(text='image can be taken from\n'+"Cards/"+fname+".png",background='white',anchor=CENTER)
            else :
                image_zone.config(text='clic to choose image',background='white',anchor=CENTER)

        #image_zone.pack()
        
        
        # POWER ZONE
        power_zone=PanedWindow(self.card_win, orient=VERTICAL)
        #fenetre=self.card_win.master
        def removePowerCreator(px) :
            def removePower(*args) :
                #print 'avant',list_pow
                self.bonus.remove(px)
                #print 'apres',list_pow
                #self.card_win.pack_forget()
                self.refreshWidget()
            return removePower
        for p in self.bonus :
            powline =  PanedWindow(self.card_win, orient=HORIZONTAL)
            pow_wid=p.initWidget(powline)
            powline.add(pow_wid)
            removepow=Button(powline, text="X", command=removePowerCreator(p), anchor=E)
            removepow.pack()
            powline.add(removepow)
            power_zone.add(powline) 
        def addPower(*args) :
            if addBonus.get()!= "add bonus":
                name=addBonus.get()
            else:
                name=add_cost_alteration.get()
            print ("added :",name)
            import CardPowers
            self.bonus+=[eval('CardPowers.'+name+'()')]
            self.bonus[-1].parent=self.bonus
            self.bonus[-1].card=self
            #self.card_win.pack_forget()
            self.refreshWidget()
        #Add bonus Option menu
        addBonus = StringVar(power_zone)
        addBonus.set("add bonus") # default value
        if not self.pv:  
            addBonus_wid = Spell.getSpellMenu(power_zone, addBonus)
        else: addBonus_wid = getBonusMenu(power_zone, addBonus) 
        addBonus.trace('w', addPower)
        if self.pv>0 or len(self.bonus)==0 or all([b.is_cost_alterator for b in self.bonus]):
            addBonus_wid.pack()
            #Add this to power zone
            power_zone.add(addBonus_wid)
        
        #Create save zone
        save_zone = PanedWindow(self.card_win, orient=HORIZONTAL)
        if self.monster_type != "all" and not(self.name in Card.blocked_creature) :
            save_wid = Button(save_zone, text="Save", command=self.postAndSave)
        elif self.monster_type != "all" : 
            save_wid = Button(save_zone, text="creature in campaign", command=None)
        else:
            save_wid = Button(save_zone, text="nead type", command=None)
        save_wid.pack()
        #Create the open button
        save_zone.pack()        
        if Card.monster_list.keys():
            self.opening = StringVar(save_zone)
            self.opening.set("Open")
            choice = [na for na in Card.monster_list.keys() if na not in Card.blocked_creature]
            choice.sort()
            #print all_monsters.keys()
            open_wid = OptionMenu(save_zone, self.opening,*choice)
            self.opening.trace('w', self.Open)
            open_wid.pack()
            save_zone.add(open_wid)
        
        if Card.monster_list.keys():
            self.delete = StringVar(save_zone)
            self.delete.set("Delete")
            choice = [na for na in Card.monster_list.keys() if na not in Card.blocked_creature]
            choice.sort()
            delete_wid = OptionMenu(save_zone, self.delete,*choice)
            self.delete.trace('w', self.clicDelete)
            delete_wid.pack()
            save_zone.add(delete_wid)
        
        #Create the type button
        self.category = StringVar(save_zone)
        self.category.set(self.monster_type)
        choice = [file2name(t,"_monsters.sav") for t in glob.glob("CardFiles/*_monsters.sav")]
        if "recup" in choice:
            choice.remove("recup")
        #print all_monsters.keys()
        category_wid = OptionMenu(save_zone, self.category,*choice)
        self.category.trace('w', self.setFile)
        
        
        
        category_wid.pack()
        
        #Add it to save zone
        save_zone.add(save_wid)
        save_zone.add(category_wid)
        
        #Create a new Strength zone for att and pv
        strength_zone=PanedWindow(self.card_win, orient=HORIZONTAL)
        att=StringVar()
        att.set(str(self.att))
        pv=StringVar() ; pv.set(str(self.pv))
        def modifiedAttPv(*args) :
            print ("modifiedAttPv")
            self.pv=int(pv.get())
            if self.pv<1 and self.is_spell==False :
                if len(self.bonus)==0 :
                    self.is_spell=True
                    self.refreshWidget()
                else :
                    self.pv=1
                    self.refreshWidget()
            if self.pv>0 and self.is_spell==True :
                if len(self.bonus)==0 :
                    self.is_spell=False
                    self.refreshWidget()
                else :
                    self.pv=0
                    self.refreshWidget()            
            self.att=int(att.get())
            self.getCost()
        att_wid = Spinbox(strength_zone, from_=0, to=1000,textvariable=att,command=modifiedAttPv)
        att_wid.pack()
        strength_zone.add(att_wid)
        strength_zone.add(Label(strength_zone, text='       ', background='white', 
             anchor=CENTER))
        pv_wid = Spinbox(strength_zone, from_=0, to=1000,textvariable=pv,command=modifiedAttPv)
        pv_wid.pack()
        strength_zone.add(pv_wid)
        
        #Put it all in window
        self.card_win.add(name_zone)
        self.card_win.add(image_zone)
        self.card_win.add(power_zone)  
        self.card_win.add(strength_zone)
        self.card_win.add(save_zone)
        
        
        self.card_win.pack()                      
Esempio n. 46
0
    def __init__(self, *args, **kwargs):
        '''
node_name:   The name of this node. Usually set by ModelNode.__setattr__ automatically.
figure_meta: Meta information of figure.
The rest parameters are passed to PanedWindow.__init__.
'''
        node_name    = kwargs.pop('node_name', '')
        super().__init__(node_name=node_name)

        figure_meta = None if 'figure_meta' not in kwargs \
            else kwargs.pop('figure_meta')
        kwargs['orient'] = 'horizontal'
        
        paned_window = PanedWindow(*args, **kwargs)

        paned_window.config(sashwidth=4, sashrelief='groove', bg='forestgreen')        
       
#        figureTabsStyle = Style()
#        figureTabsStyle.configure('Figure.TNotebook', tabposition='sw')       
#        figureTabs    = Notebook(paned_window, style='Figure.TNotebook')
        figureTabs  = Notebook(paned_window)
        
        self.figureTabs   = figureTabs
        figureTabs.bind('<<NotebookTabChanged>>', self._on_tab_change)
        self.lock_attribute('figureTabs')
        
        if figure_meta:
            self.make_figures(figure_meta)
            
        self.lock_elements()    
        
        paned_window.add(figureTabs, stretch='always')
        

        listPan     = PanedWindow(paned_window, orient='vertical')
        listPan.config(sashwidth=4, sashrelief='groove', bg='forestgreen')        
        paned_window.add(listPan, stretch='never')

        
        listFrm     = Frame(listPan)
        listPan.add(listFrm, stretch='always')        
        Label(listFrm, text='Curves', bg='#b5d6b0').pack(side='top', fill='x')
        self.__list = ScrolledList(listFrm, relief='groove')
        self.__list.list_config(width=20)
        self.__list.list_click_callback = self._on_list_click
        self.__list.pack(fill='both', expand='yes')

        listFrm     = Frame(listPan)        
        listPan.add(listFrm, stretch='never')
        Label(listFrm, text='Indicators', bg='#b5d6b0').pack(side='top', fill='x')
        self.__indicator_listbox = ScrolledList(listFrm, relief='groove')
        self.__indicator_listbox.list_config(width=20)
        self.__indicator_listbox.pack(fill='both', expand='yes')
                      
        with self.attribute_lock:
            set_attributes(self,
                paned_window = paned_window,
                grid_group_observer = self.GridGroupObserver(self), 
                axis_group_observer = self.AxisGroupObserver(self),
                clear_group_observer = self.ClearGroupObserver(self),
                label_group_observer = self.LabelGroupObserver(self),
                indicator_group_observer = self.IndicatorGroupObserver(self),
                data_figure_observer = self.DataFigureObserver(self),
                data_pool    = []
            )
Esempio n. 47
0
def main():
    root=tk.Tk()

    main_paned_window = PanedWindow(root)
    main_paned_window.pack(fill=BOTH, expand=1)

    tone_curve_paned_window=PanedWindow(main_paned_window)
    main_paned_window.add(tone_curve_paned_window)
    
    tone_curve_window=PanedWindow(tone_curve_paned_window,relief=tk.GROOVE,bd=3,orient=tk.VERTICAL)
    mlp_tone_curve_window=MatplotlibWindow2(tone_curve_window)
    mlp_tone_curve_window.canvas.get_tk_widget().pack(fill=tk.BOTH,expand=True)

    #text_panel_left = Text(main_paned_window, height=6, width =15,relief=tk.GROOVE,bd=2)
    #main_paned_window.add(text_panel_left)

    sub_paned_window = PanedWindow(main_paned_window, orient=tk.VERTICAL)

    #plot sin curve
    plot_paned_window=PanedWindow(sub_paned_window,relief=tk.GROOVE,bd=3,orient=tk.VERTICAL)
    mlp_window=MatplotlibWindow(plot_paned_window)
    mlp_window.canvas.get_tk_widget().pack(fill=tk.BOTH,expand=True)


    main_paned_window.add(sub_paned_window)
    bottom_pane_text = Text(sub_paned_window, height=3, width =3, relief=tk.SUNKEN,bd=2)
    
    sub_paned_window.add(plot_paned_window)
    sub_paned_window.add(bottom_pane_text)




    button=Button(root,text="Hello")
    button.pack()

    root.mainloop()
Esempio n. 48
0
 def createfilelistpanel(self, parent):
     panel = PanedWindow(parent, orient=VERTICAL)
     for file in self.files:
         panel.add(self.createfilepanel(panel, file))
     return panel
Esempio n. 49
0
def pack_windows(root):
    main_paned_window = PanedWindow(root)
    main_paned_window.pack(fill=BOTH, expand=True)

    tone_paned_window=PanedWindow(relief=tk.GROOVE,bd=3,orient=tk.VERTICAL)
    main_paned_window.add(tone_paned_window)
    
    sub_tone_paned_window=PanedWindow(tone_paned_window)
    tone_paned_window.add(sub_tone_paned_window)
    
    plot_window=PanedWindow()
    main_paned_window.add(plot_window)
    plot_window=ImageViewer(plot_window)
    plot_window.canvas.get_tk_widget().pack(fill=tk.BOTH,expand=True)

    tone_window=ToneCurveViewer(sub_tone_paned_window,plot_window)
    tone_window.canvas.get_tk_widget().pack(fill=tk.BOTH,expand=True)
    space_frame=Frame()
    tone_paned_window.add(space_frame)
    
    button=Button(space_frame,text="something")
    button.pack()

    def quit_app():
        root.quit()
        root.destroy()

    quitbutton=Button(space_frame,text="exit",command=quit_app)
    quitbutton.pack()
Esempio n. 50
0
    def BuildMainFrame(self): 
        from tkinter import Menu, IntVar, StringVar, Toplevel, Listbox, Frame, PanedWindow, Text, Scrollbar, Entry
        from tkinter import X, N, S, W, E, VERTICAL, TOP, END, DISABLED, RAISED

        menu = Menu(self.master,activeborderwidth=0,bd=0)
        self.master.config(menu=menu)
  
        filemenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
        menu.add_cascade(label="File", underline=0,  menu=filemenu)
        filemenu.add_command(label="New", accelerator='Ctrl+N',command=self.NewCommand)
        filemenu.add_command(label="Open...",accelerator='Ctrl+O', command=self.OpenCommand)
        filemenu.add_command(label="Save as...",accelerator='Ctrl+S', command=self.SaveCommand)
        filemenu.add_separator()
        filemenu.add_command(label="Quit",accelerator='Ctrl+Q', command=self.QuitCommand)

        self.log_on = IntVar()
        self.log_on.set(1)
  
        self.output_to_file = StringVar()
        self.output_to_file.set('n')
 
        scriptmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
        modulenames = ['vmtkscripts']
        for modulename in modulenames:
            scriptsubmenu = self.BuildScriptMenu(menu,modulename)
            if scriptsubmenu:
                scriptmenu.add_cascade(label=modulename,menu=scriptsubmenu)
 
        editmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
        menu.add_cascade(label="Edit",underline=0,  menu=editmenu)
        editmenu.add_cascade(label="Insert script",menu=scriptmenu)
        editmenu.add_command(label="Insert file name", accelerator='Ctrl+F',command=self.InsertFileName)
        editmenu.add_separator()
        editmenu.add_command(label="Clear input", command=self.ClearInputCommand)
        editmenu.add_command(label="Clear output", command=self.ClearOutputCommand)
        editmenu.add_command(label="Clear all", command=self.ClearAllCommand)
        editmenu.add_separator()
        editmenu.add_checkbutton(label="Log", variable=self.log_on)
        editmenu.add_separator()
        editmenu.add_radiobutton(label="No output to file", variable=self.output_to_file,value='n')
        editmenu.add_radiobutton(label="Write output to file", variable=self.output_to_file,value='w')
        editmenu.add_radiobutton(label="Append output to file", variable=self.output_to_file,value='a')
        editmenu.add_command(label="Output file...", command=self.OutputFileCommand)

        runmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
        menu.add_cascade(label="Run", underline=0, menu=runmenu)
        runmenu.add_command(label="Run all", command=self.RunAllCommand)
        runmenu.add_command(label="Run current line", command=self.RunLineCommand)
        runmenu.add_command(label="Run selection", command=self.RunSelectionCommand)
       
        helpmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
        menu.add_cascade(label="Help", underline=0, menu=helpmenu)
        helpmenu.add_command(label="Help", underline=0, accelerator='F1',command=self.ShowHelpCommand)
        helpmenu.add_command(label="About", underline=0, command=self.AboutCommand)

        self.master.bind("<Control-KeyPress-q>", self.QuitHandler)
        self.master.bind("<Control-KeyPress-n>", self.NewHandler)
        self.master.bind("<Control-KeyPress-o>", self.OpenHandler)
        self.master.bind("<Control-KeyPress-s>", self.SaveHandler)
        self.master.bind("<Control-KeyPress-f>", self.InsertFileNameHandler)
        self.master.bind("<KeyPress-F1>", self.ShowHelpHandler)
        self.master.bind("<KeyPress>", self.KeyPressHandler)
        
        self.wordIndex = ['1.0','1.0']
               
        self.suggestionswindow = Toplevel(bg='#ffffff',bd=0,height=50,width=600,highlightthickness=0,takefocus=True)
        self.suggestionswindow.overrideredirect(1)
        self.suggestionslist = Listbox(self.suggestionswindow,bg='#ffffff',bd=1,fg='#336699',activestyle='none',highlightthickness=0,height=9)
        self.suggestionslist.insert(END,"foo")
        self.suggestionslist.pack(side=TOP,fill=X)
        self.suggestionswindow.bind("<KeyPress>", self.TopKeyPressHandler)
        self.suggestionswindow.withdraw()

        self.master.rowconfigure(0,weight=1)
        self.master.columnconfigure(0,weight=1)
        content = Frame(self.master,bd=0,padx=2,pady=2) 
        content.grid(row=0,column=0,sticky=N+S+W+E)
        content.rowconfigure(0,weight=1,minsize=50)
        content.rowconfigure(1,weight=0)
        content.columnconfigure(0,weight=1)

        panes = PanedWindow(content,orient=VERTICAL,bd=1,sashwidth=8,sashpad=0,sashrelief=RAISED,showhandle=True)
        panes.grid(row=0,column=0,sticky=N+S+W+E)

        frame1 = Frame(panes,bd=0) 
        frame1.grid(row=0,column=0,sticky=N+S+W+E)
        frame1.columnconfigure(0,weight=1)
        frame1.columnconfigure(1,weight=0)
        frame1.rowconfigure(0,weight=1)

        panes.add(frame1,height=300,minsize=20)        

        frame2 = Frame(panes,bd=0) 
        frame2.grid(row=1,column=0,sticky=N+S+W+E)
        frame2.columnconfigure(0,weight=1)
        frame2.columnconfigure(1,weight=0)
        frame2.rowconfigure(0,weight=1)
        
        panes.add(frame2,minsize=20) 
 
        self.text_input = Text(frame1, bg='#ffffff',bd=1,highlightthickness=0)

        self.text_input.bind("<KeyPress>", self.KeyPressHandler)
        self.text_input.bind("<Button-3>", self.PopupHandler)
        self.text_input.bind("<Control-Return>", self.RunKeyboardHandler)
 
        self.input_scrollbar = Scrollbar(frame1,orient=VERTICAL,command=self.text_input.yview)
        self.text_input["yscrollcommand"] = self.input_scrollbar.set    

        self.text_output = Text(frame2,state=DISABLED,bd=1,bg='#ffffff',highlightthickness=0)
        
        self.output_scrollbar = Scrollbar(frame2,orient=VERTICAL,command=self.text_output.yview)
        self.text_output["yscrollcommand"] = self.output_scrollbar.set    
      
        self.text_entry = Entry(content,bd=1,bg='#ffffff',state=DISABLED,highlightthickness=0)

        self.text_input.focus_set()

        self.text_input.grid(row=0,column=0,sticky=N+S+W+E)
        self.input_scrollbar.grid(row=0,column=1,sticky=N+S+W+E)
        self.text_output.grid(row=0,column=0,sticky=N+S+W+E)
        self.output_scrollbar.grid(row=0,column=1,sticky=N+S+W+E)
        self.text_entry.grid(row=1,column=0,sticky=N+S+W+E)

        self.popupmenu = Menu(self.text_input, tearoff=1, bd=0)
        self.popupmenu.add_command(label="Context help", command=self.ShowHelpCommand)
        self.popupmenu.add_cascade(label="Insert script",menu=scriptmenu)
        self.popupmenu.add_command(label="Insert file name...", command=self.InsertFileName)
        self.popupmenu.add_separator()
        self.popupmenu.add_command(label="Run all", command=self.RunAllCommand)
        self.popupmenu.add_command(label="Run current line", command=self.RunLineCommand)
        self.popupmenu.add_command(label="Run selection", command=self.RunSelectionCommand)

        self.output_stream = TkPadOutputStream(self.text_output)
        self.input_stream = TkPadInputStream(self.text_entry,self.output_stream)
Esempio n. 51
0
class ResultFrame(FrameTemplate):
    """Frame for display of equilibria in the conflict."""

    # Label used for button to select frame in the main program.
    buttonLabel = 'Equilibria Results'
    # Image used on button to select frame, when frame is active.
    activeIcon = 'icons/Equilibria_Results_ON.gif'
    # Image used on button to select frame, when frame is inactive.
    inactiveIcon = 'icons/Equilibria_Results_OFF.gif'
    # Help text to be displayed when screen is active.
    helpText = ("The stability of each state in the conflict is shown in the "
                "table on the left, giving results under a number of different"
                " stability criterion. The display on the right allows the "
                "logic which defines the stability or instability of each "
                "option to be examined.")

# ########################     INITIALIZATION  ################################
    def __init__(self, master, conflict, *args):
        """Initialize the Frame. Does not build widgets."""
        FrameTemplate.__init__(self, master, conflict, self.buttonLabel,
                               self.activeIcon, self.inactiveIcon,
                               self.helpText)

        self.lastBuildConflict = None

# ############################     METHODS  ###################################

    def hasRequiredData(self):
        """Check that minimum data required to render the frame exists."""
        if len(self.conflict.decisionMakers) < 1:
            return False
        if len(self.conflict.options) < 1:
            return False
        if len(self.conflict.feasibles) < 1:
            return False
        if self.conflict.preferenceErrors:
            return False
        else:
            return True

    def dataChanged(self):
        """Check if data has changed since the last build of the Frame."""
        if self.lastBuildConflict != self.conflict.export_rep():
            return True
        else:
            return False

    def buildFrame(self):
        """Contruct frame widgets and initialize data."""
        if self.built:
            return

        # Ensure all required parts of the conflict model are properly set-up.
        self.conflict.reorderOptionsByDM()
        self.conflict.options.set_indexes()
        self.conflict.infeasibles.validate()
        self.conflict.recalculateFeasibleStates()
        self.conflict.coalitions.validate()

        for dm in self.conflict.decisionMakers:
            dm.calculatePerceived()
            dm.calculatePreferences()

        self.lastBuildConflict = self.conflict.export_rep()

        # Define variables that will display in the infoFrame
        self.infoText = StringVar(value='')

        # Define frame-specific variables
        self.sol = LogicalSolver(self.conflict)
        self.sol.findEquilibria()

        # infoFrame: frame and label definitions (with master 'self.infoFrame')
        self.infoLabel = ttk.Label(self.infoFrame, textvariable=self.infoText)

        # helpFrame: frame and label definitions (with master 'self.helpFrame')
        self.helpLabel = ttk.Label(self.helpFrame, textvariable=self.helpVar,
                                   wraplength=150)

        # Define frame-specific input widgets (with 'self' as master)
        self.paneMaster = PanedWindow(self, orient=HORIZONTAL, sashwidth=10,
                                      sashrelief="raised", sashpad=3,
                                      relief="sunken")

        self.pane1 = ttk.Frame(self.paneMaster)
        self.coalitionSelector = CoalitionSelector(self.pane1, self.conflict,
                                                   self)
        self.solutionTable = OptionFormSolutionTable(self.pane1, self.conflict,
                                                     self)
        self.exporter = Exporter(self.pane1, self.conflict, self)

        self.pane2 = ttk.Frame(self.paneMaster)
        self.narrator = LogNarrator(self.pane2, self.conflict, self)

        # ########  preliminary gridding and option configuration

        # configuring the input frame
        self.grid(column=0, row=0, rowspan=5, sticky=NSEW)
        self.grid_remove()
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        # configuring infoFrame & infoFrame widgets
        self.infoFrame.grid(column=2, row=0, sticky=NSEW, padx=3, pady=3)
        self.infoFrame.grid_remove()
        self.infoLabel.grid(column=0, row=1, sticky=NSEW)

        # configuring helpFrame & helpFrame widgets
        self.helpFrame.grid(column=2, row=1, sticky=NSEW, padx=3, pady=3)
        self.helpFrame.grid_remove()
        self.helpLabel.grid(column=0, row=0, sticky=NSEW)

        # configuring frame-specific options
        self.paneMaster.grid(column=0, row=1, sticky=NSEW)
        self.paneMaster.add(self.pane1, width=600, stretch='always')
        self.pane1.rowconfigure(1, weight=1)
        self.pane1.columnconfigure(0, weight=1)
        self.coalitionSelector.grid(row=0, column=0, sticky=NSEW)
        self.solutionTable.grid(row=1, column=0, sticky=NSEW)
        self.exporter.grid(row=2, column=0, sticky=NSEW)

        self.paneMaster.add(self.pane2, width=250, stretch='always')
        self.pane2.rowconfigure(0, weight=1)
        self.pane2.columnconfigure(0, weight=1)
        self.narrator.grid(row=0, column=0, sticky=NSEW)

        # bindings
        self.coalitionSelector.bind("<<CoalitionsChanged>>",
                                    self.refresh)

        self.built = True

    def refresh(self, *args):
        """Refresh data in all active display widgets."""
        self.sol = LogicalSolver(self.conflict)
        self.sol.findEquilibria()
        self.coalitionSelector.refresh()
        self.solutionTable.refresh()
        self.narrator.refresh()