Ejemplo n.º 1
0
    def draw_table(self):
        self.attack_table = tksheet.Sheet(self.screen, total_columns=5, total_rows=0,
                                          show_x_scrollbar=False, width=645, height=300)
        self.save_table = tksheet.Sheet(self.screen, total_columns=7, total_rows=0,
                                        show_x_scrollbar=False, width=875, height=300)

        self.attack_table.headers((f"{header}" for header in self.__attack_table_headers))
        self.save_table.headers((f"{header}" for header in self.__save_table_headers))

        self.save_table.grid(row=1, column=0, sticky="w")
        self.attack_table.grid(row=0, column=0)
Ejemplo n.º 2
0
    def search():
        search_frame = tk.Toplevel(list_frame)
        search_frame.title("Search Results")
        word = name_var.get()
        search_label = tk.Label(search_frame,
                                text="Search Results for {}".format(word))

        res = []
        with open('pharmdata.csv', mode='r') as file:
            rows = list(csv.reader(file))
        file.close()
        # print(rows)
        for row in rows:
            for col in row:
                if word in col.lower():
                    # print(row)
                    res.append(row)

        search_label.grid(row=0)
        sheet1 = tksheet.Sheet(search_frame)
        sheet1.grid(row=1)
        sheet1.set_sheet_data([[f"{col}" for col in row] for row in res])

        sheet1.enable_bindings(
            ("single_select", "row_select", "column_width_resize", "arrowkeys",
             "rc_select", "copy", "right_click_popup_menu"))
        search_frame.grid()
Ejemplo n.º 3
0
    def __init__(self, parent: RegistrationWindow):
        top = parent.top
        self.parent = parent
        self.top = top
        self._outer_frame = tk.Frame(top)

        headers = ["Lane 1", "Lane 2", "Lane 3", "Lane 4"]

        self.sheet = tksheet.Sheet(self._outer_frame,
                                   headers=headers,
                                   column_width=240,
                                   width=900)
        self._outer_frame.pack(fill=tk.BOTH, expand=True, side=tk.RIGHT)

        self.sheet.pack(fill=tk.BOTH, expand=True)

        self.sheet.enable_bindings(
            ("single_select", "row_select", "column_width_resize", "arrowkeys",
             "right_click_popup_menu", "rc_select", "rc_insert_row",
             "rc_delete_row", "copy", "cut", "paste", "delete", "undo",
             "edit_cell"))

        self.sheet_data = self.sheet.set_sheet_data(
            self.parent.event.get_race_plan())

        self.highlighted_cells = []
    def set_sheet(self, my_frame: Frame) -> None:
        self.NB: Notebook = Notebook(my_frame)
        self.NB.pack(anchor=N, fill="both", expand=True)
        self.NBF: List[Frame] = []
        self.NBS: List[tksheet.Sheet] = []
        self.NB_DF: List[pd.Dataframe] = []

        df, dict_dfs = self.append_df_with_OC()
        for key in dict_dfs.keys():
            self.NBF.append(Frame(self.NB))
            self.NB_DF.append(pd.concat([df, dict_dfs[key]], axis=1))
            self.NB.add(self.NBF[-1], text=key)
            sh = tksheet.Sheet(self.NBF[-1],
                               column_width=80,
                               align="center",
                               headers=list(self.NB_DF[-1].columns),
                               header_font=("TkDefaultFont", 10, "bold"),
                               empty_horizontal=0,
                               empty_vertical=20,
                               header_height=35)
            sh.enable_bindings(
                ("toggle_select", "drag_select", "column_select", "row_select",
                 "column_width_resize", "arrowkeys", "right_click_popup_menu",
                 "rc_select", "copy", "select_all"))
            sh.pack(anchor=W, fill="both", expand=True)
            self.NBS.append(sh)
Ejemplo n.º 5
0
 def Table(self, x=0, y=0, w=15, h=15, headers=[], indexes=[], data=[]):
     div_x = self.resol["x"] / 64
     div_y = self.resol["y"] / 28
     Table = tksheet.Sheet(
         self,
         row_index_foreground=self.forecolor,
         row_index_background="#222222",
         header_background="#222222",
         header_foreground=self.forecolor,
         table_background=self.backcolor,
         text_color=self.forecolor,
         grid_color=self.backcolor,
         outline_color=self.forecolor,
         outline_thickness=1,
         show_x_scrollbar=False,
         show_y_scrollbar=True,
         header_font=("Arial", 8, "bold", "underline"),
         font=("Arial", 8, "normal"),
         data=data,
         headers=headers,
         row_index=indexes,
         row_index_width=0.6 * w * div_x / (len(headers) + 0.4),
         column_width=0.8 * w * div_x / (len(headers) + 0.4),
         width=w * div_x,
         height=h * div_y)
     Table.place(x=x * div_x, y=y * div_y)
     return (Table)
Ejemplo n.º 6
0
def medicine_page(root):
    name_var = tk.StringVar()

    def search():
        search_frame = tk.Toplevel(list_frame)
        search_frame.title("Search Results")
        word = name_var.get()
        search_label = tk.Label(search_frame,
                                text="Search Results for {}".format(word))

        res = []
        with open('pharmdata.csv', mode='r') as file:
            rows = list(csv.reader(file))
        file.close()
        # print(rows)
        for row in rows:
            for col in row:
                if word in col.lower():
                    # print(row)
                    res.append(row)

        search_label.grid(row=0)
        sheet1 = tksheet.Sheet(search_frame)
        sheet1.grid(row=1)
        sheet1.set_sheet_data([[f"{col}" for col in row] for row in res])

        sheet1.enable_bindings(
            ("single_select", "row_select", "column_width_resize", "arrowkeys",
             "rc_select", "copy", "right_click_popup_menu"))
        search_frame.grid()

    list_frame = tk.Frame(root, bg="grey")
    label2 = tk.Label(list_frame, text="List of Medicines", bg="grey")
    btn_back_to_main = tk.Button(list_frame, text="Back", command=changepage)
    btn_edit_list = tk.Button(list_frame,
                              text="Edit List",
                              command=changepage1)
    btn_search = tk.Button(list_frame, text="Search", command=search)
    search_input = tk.Entry(list_frame, textvariable=name_var)

    label2.grid(row=0, columnspan=2, pady=10)
    btn_back_to_main.grid(row=1, column=0)
    btn_edit_list.grid(row=2, column=0)
    btn_search.grid(row=1, column=1)
    search_input.grid(row=2, column=1)

    sheet = tksheet.Sheet(list_frame)
    sheet.grid(row=3, columnspan=2)
    with open('pharmdata.csv', 'rt') as f1:
        data = csv.reader(f1)
        sheet.set_sheet_data([[f"{col}" for col in row] for row in data])
    # table enable choices listed below:
    sheet.enable_bindings(
        ("single_select", "row_select", "column_width_resize", "arrowkeys",
         "rc_select", "copy", "right_click_popup_menu"))
    f1.close()
    list_frame.grid()
Ejemplo n.º 7
0
def edit_page(root):
    def save():
        print("Saving the info")
        data = sheet1.get_sheet_data(return_copy=True,
                                     get_header=False,
                                     get_index=False)
        with open('pharmdata.csv', mode='w', newline='') as file:
            writer = csv.writer(file,
                                delimiter=',',
                                quotechar='"',
                                quoting=csv.QUOTE_MINIMAL)
            writer.writerows(data)
        file.close()
        print(data)

    edit_list_frame = tk.Frame(root, bg="grey")
    label3 = tk.Label(edit_list_frame,
                      text="List of Medicines(Edit Mode)",
                      bg="grey")
    btn_back_to_list_view = tk.Button(edit_list_frame,
                                      text="Back",
                                      command=changepage)
    btn_save = tk.Button(edit_list_frame, text="Save", command=save)

    label3.grid(row=0)
    btn_back_to_list_view.grid(row=1)
    btn_save.grid(row=2)

    sheet1 = tksheet.Sheet(edit_list_frame)
    sheet1.grid(row=3)
    with open('pharmdata.csv', 'rt') as f2:
        data = csv.reader(f2)
        sheet1.set_sheet_data([[f"{col}" for col in row] for row in data])
    # table enable choices listed below:
    sheet1.enable_bindings(
        ("single_select", "row_select", "column_width_resize", "arrowkeys",
         "right_click_popup_menu", "rc_select", "rc_insert_row",
         "rc_insert_row_below", "rc_delete_row", "copy", "cut", "paste",
         "delete", "undo", "edit_cell"))
    f2.close()
    edit_list_frame.grid()
Ejemplo n.º 8
0
    def showResults(self):
        titration = self.titration
        kTable = Table(
            self,
            0,
            0,
            ["K (M⁻ⁿ)", "α"],
            rowOptions=("readonlyTitles", ),
            columnOptions=("readonlyTitles", ),
        )

        ks = self.titration.knownKs.copy()
        ks[np.isnan(ks)] = 10**titration.lastKs[:titration.kVarsCount()]

        alphas = titration.knownAlphas.copy()
        polymerAlphas = alphas[np.any(titration.stoichiometries < 0, 1)]
        polymerAlphas[np.isnan(polymerAlphas)] = (
            10**titration.lastKs[titration.kVarsCount() +
                                 titration.getConcVarsCount():])

        for boundName, k, alpha in zip(self.titration.boundNames, ks, alphas):
            kTable.addRow(boundName,
                          [np.rint(k), alpha if not np.isnan(alpha) else ""])
        kTable.pack(side="top", pady=15)

        sheet = tksheet.Sheet(
            self,
            data=list(np.around(titration.lastFitResult, 2)),
            headers=list(titration.processedSignalTitlesStrings),
            row_index=list(titration.contributorNames()),
            set_all_heights_and_widths=True,
        )
        sheet.enable_bindings()
        sheet.pack(side="top", pady=15, fill="x")

        saveButton = ttk.Button(self,
                                text="Save as CSV",
                                command=self.saveCSV,
                                style="success.TButton")
        saveButton.pack(side="top", pady=15)
Ejemplo n.º 9
0
 def sheets(self) :
     self.sheet = tksheet.Sheet(self.tab3,
                                page_up_down_select_row=True,
                                 # empty_vertical = 0,
                                 column_width=120,
                                 startup_select=(0, 1, "rows"),
                                 # row_height = "4",
                                 # default_row_index = "numbers",
                                 # default_header = "both",
                                 # empty_horizontal = 0,
                                 # show_vertical_grid = False,
                                 # show_horizontal_grid = False,
                                 # auto_resize_default_row_index = False,
                                 # header_height = "3",
                                 # row_index_width = 100,
                                 # align = "e",
                                 # header_align = "w",
                                 # row_index_align = "w",
                                 # data = [[f"Row {r}, Column {c}\nnewline1\nnewline2" for c in range(50)] for r in range(1000)], #to set sheet data at startup
                                 # headers = [f"Column {c}\nnewline1\nnewline2" for c in range(30)],
                                 # row_index = [f"Row {r}\nnewline1\nnewline2" for r in range(2000)],
                                 # set_all_heights_and_widths = True, #to fit all cell sizes to text at start up
                                 # headers = 0, #to set headers as first row at startup
                                 # headers = [f"Column {c}\nnewline1\nnewline2" for c in range(30)],
                                 # theme = "light green",
                                 # row_index = 0, #to set row_index as first column at startup
                                 # total_rows = 2000, #if you want to set empty sheet dimensions at startup
                                 # total_columns = 30, #if you want to set empty sheet dimensions at startup
                                 height=500,  # height and width arguments are optional
                                 width=1200  # For full startup arguments see DOCUMENTATION.md
                                 )
     self.sheet.grid()
     # table enable choices listed below:
     self.sheet.enable_bindings(("single_select", "row_select", "column_width_resize",
                                 "arrowkeys", "right_click_popup_menu", "rc_select", "rc_insert_row",
                                 "rc_delete_row", "copy", "cut", "paste", "delete", "undo", "edit_cell"))
    def main_win(self):
        self.root = Tk()
        self.root.focus_force()
        self.root.title("NSE-Option-Chain-Analyzer")
        self.root.protocol('WM_DELETE_WINDOW', self.close)
        window_width = self.root.winfo_reqwidth()
        window_height = self.root.winfo_reqheight()
        position_right = int(self.root.winfo_screenwidth() / 3 -
                             window_width / 2)
        position_down = int(self.root.winfo_screenheight() / 3 -
                            window_height / 2)
        self.root.geometry("815x510+{}+{}".format(position_right,
                                                  position_down))
        self.root.rowconfigure(0, weight=1)
        self.root.columnconfigure(0, weight=1)

        menubar = Menu(self.root)
        self.options = Menu(menubar, tearoff=0)
        self.options.add_command(label="Stop   (Ctrl+X)",
                                 command=self.change_state)
        self.options.add_command(label="Export to CSV   (Ctrl+S)",
                                 command=self.export)
        self.options.add_command(label="Logging: Off   (Ctrl+L)",
                                 command=self.log)
        self.options.add_separator()
        self.options.add_command(label="About   (Ctrl+M)", command=self.about)
        self.options.add_command(label="Quit   (Ctrl+Q)", command=self.close)
        menubar.add_cascade(label="Menu", menu=self.options)
        self.root.config(menu=menubar)

        self.root.bind('<Control-s>', self.export)
        self.root.bind('<Control-l>', self.log)
        self.root.bind('<Control-x>', self.change_state)
        self.root.bind('<Control-m>', self.about)
        self.root.bind('<Control-q>', self.close)

        top_frame = Frame(self.root)
        top_frame.rowconfigure(0, weight=1)
        top_frame.columnconfigure(0, weight=1)
        top_frame.pack(fill="both", expand=True)

        output_columns = ('Time', 'Value', 'Call Sum\n(in K)',
                          'Put Sum\n(in K)', 'Difference\n(in K)',
                          'Call Boundary\n(in K)', 'Put Boundary\n(in K)',
                          'Call ITM', 'Put ITM')
        self.sheet = tksheet.Sheet(top_frame,
                                   column_width=85,
                                   align="center",
                                   headers=output_columns,
                                   header_font=("TkDefaultFont", 9, "bold"),
                                   empty_horizontal=0,
                                   empty_vertical=20,
                                   header_height=35)
        self.sheet.enable_bindings(
            ("toggle_select", "drag_select", "column_select", "row_select",
             "column_width_resize", "arrowkeys", "right_click_popup_menu",
             "rc_select", "copy", "select_all"))
        self.sheet.grid(row=0, column=0, sticky=N + S + W + E)

        bottom_frame = Frame(self.root)
        bottom_frame.rowconfigure(0, weight=1)
        bottom_frame.rowconfigure(1, weight=1)
        bottom_frame.rowconfigure(2, weight=1)
        bottom_frame.rowconfigure(3, weight=1)
        bottom_frame.rowconfigure(4, weight=1)
        bottom_frame.columnconfigure(0, weight=1)
        bottom_frame.columnconfigure(1, weight=1)
        bottom_frame.columnconfigure(2, weight=1)
        bottom_frame.columnconfigure(3, weight=1)
        bottom_frame.columnconfigure(4, weight=1)
        bottom_frame.columnconfigure(5, weight=1)
        bottom_frame.columnconfigure(6, weight=1)
        bottom_frame.columnconfigure(7, weight=1)
        bottom_frame.pack(fill="both", expand=True)

        oi_ub_label = Label(bottom_frame,
                            text="Open Interest Upper Boundary",
                            relief=RIDGE,
                            font=("TkDefaultFont", 10, "bold"))
        oi_ub_label.grid(row=0, column=0, columnspan=4, sticky=N + S + W + E)
        max_call_oi_sp_label = Label(bottom_frame,
                                     text="Strike Price:",
                                     relief=RIDGE,
                                     font=("TkDefaultFont", 9, "bold"))
        max_call_oi_sp_label.grid(row=1, column=0, sticky=N + S + W + E)
        self.max_call_oi_sp_val = Label(bottom_frame, text="", relief=RIDGE)
        self.max_call_oi_sp_val.grid(row=1, column=1, sticky=N + S + W + E)
        max_call_oi_label = Label(bottom_frame,
                                  text="OI (in K):",
                                  relief=RIDGE,
                                  font=("TkDefaultFont", 9, "bold"))
        max_call_oi_label.grid(row=1, column=2, sticky=N + S + W + E)
        self.max_call_oi_val = Label(bottom_frame, text="", relief=RIDGE)
        self.max_call_oi_val.grid(row=1, column=3, sticky=N + S + W + E)
        oi_lb_label = Label(bottom_frame,
                            text="Open Interest Lower Boundary",
                            relief=RIDGE,
                            font=("TkDefaultFont", 10, "bold"))
        oi_lb_label.grid(row=0, column=4, columnspan=4, sticky=N + S + W + E)
        max_put_oi_sp_label = Label(bottom_frame,
                                    text="Strike Price:",
                                    relief=RIDGE,
                                    font=("TkDefaultFont", 9, "bold"))
        max_put_oi_sp_label.grid(row=1, column=4, sticky=N + S + W + E)
        self.max_put_oi_sp_val = Label(bottom_frame, text="", relief=RIDGE)
        self.max_put_oi_sp_val.grid(row=1, column=5, sticky=N + S + W + E)
        max_put_oi_label = Label(bottom_frame,
                                 text="OI (in K):",
                                 relief=RIDGE,
                                 font=("TkDefaultFont", 9, "bold"))
        max_put_oi_label.grid(row=1, column=6, sticky=N + S + W + E)
        self.max_put_oi_val = Label(bottom_frame, text="", relief=RIDGE)
        self.max_put_oi_val.grid(row=1, column=7, sticky=N + S + W + E)

        oi_label = Label(bottom_frame,
                         text="Open Interest:",
                         relief=RIDGE,
                         font=("TkDefaultFont", 9, "bold"))
        oi_label.grid(row=2, column=0, columnspan=2, sticky=N + S + W + E)
        self.oi_val = Label(bottom_frame, text="", relief=RIDGE)
        self.oi_val.grid(row=2, column=2, columnspan=2, sticky=N + S + W + E)
        pcr_label = Label(bottom_frame,
                          text="PCR:",
                          relief=RIDGE,
                          font=("TkDefaultFont", 9, "bold"))
        pcr_label.grid(row=2, column=4, columnspan=2, sticky=N + S + W + E)
        self.pcr_val = Label(bottom_frame, text="", relief=RIDGE)
        self.pcr_val.grid(row=2, column=6, columnspan=2, sticky=N + S + W + E)
        call_exits_label = Label(bottom_frame,
                                 text="Call Exits:",
                                 relief=RIDGE,
                                 font=("TkDefaultFont", 9, "bold"))
        call_exits_label.grid(row=3,
                              column=0,
                              columnspan=2,
                              sticky=N + S + W + E)
        self.call_exits_val = Label(bottom_frame, text="", relief=RIDGE)
        self.call_exits_val.grid(row=3,
                                 column=2,
                                 columnspan=2,
                                 sticky=N + S + W + E)
        put_exits_label = Label(bottom_frame,
                                text="Put Exits:",
                                relief=RIDGE,
                                font=("TkDefaultFont", 9, "bold"))
        put_exits_label.grid(row=3,
                             column=4,
                             columnspan=2,
                             sticky=N + S + W + E)
        self.put_exits_val = Label(bottom_frame, text="", relief=RIDGE)
        self.put_exits_val.grid(row=3,
                                column=6,
                                columnspan=2,
                                sticky=N + S + W + E)
        call_itm_label = Label(bottom_frame,
                               text="Call ITM:",
                               relief=RIDGE,
                               font=("TkDefaultFont", 9, "bold"))
        call_itm_label.grid(row=4,
                            column=0,
                            columnspan=2,
                            sticky=N + S + W + E)
        self.call_itm_val = Label(bottom_frame, text="", relief=RIDGE)
        self.call_itm_val.grid(row=4,
                               column=2,
                               columnspan=2,
                               sticky=N + S + W + E)
        put_itm_label = Label(bottom_frame,
                              text="Put ITM:",
                              relief=RIDGE,
                              font=("TkDefaultFont", 9, "bold"))
        put_itm_label.grid(row=4, column=4, columnspan=2, sticky=N + S + W + E)
        self.put_itm_val = Label(bottom_frame, text="", relief=RIDGE)
        self.put_itm_val.grid(row=4,
                              column=6,
                              columnspan=2,
                              sticky=N + S + W + E)

        self.root.after(100, self.main)

        self.root.mainloop()
Ejemplo n.º 11
0
import tkinter as tk
from tkinter import *

import tksheet

from main import *
if __name__ == "__main__":
    window = tk.Tk()

    window.title("Sudoku Solver")

    window.geometry('210x300')

    sheet = tksheet.Sheet(window)

    sheet.grid()

    sheet.set_sheet_data([[f"{board[ri][cj]}" for cj in range(9)]
                          for ri in range(9)])

    button = tk.Button(
        window,
        text="SOLVE",
        command=lambda: [
            solve(board),
            sheet.set_sheet_data([[f"{board[ri][cj]}" for cj in range(9)]
                                  for ri in range(9)]),
            width_of_col()
        ])

    button.place(relx=0.5, rely=0.95, anchor=S)
Ejemplo n.º 12
0
#this needs tksheet to be installed.
#pip3 install tksheet
import tkinter as tk
import tksheet

top = tk.Tk()
sheet = tksheet.Sheet(top)
sheet.grid()
data = ["datasheet"]

sheet.set_sheet_data([
    #[f"{ri+cj}" for cj in range(4)]
    [f"{data[0]}" for cj in range(4)] for ri in range(4)
])

#table enable choices listed below:
sheet.enable_bindings(
    ("row_select", "column_width_resize", "arrowkeys",
     "right_click_popup_menu", "rc_select", "rc_insert_row", "rc_delete_row",
     "copy", "cut", "paste", "delete", "undo", "edit_cell"))

top.mainloop()
Ejemplo n.º 13
0
    def setup_main_window(self,window)->None:
        self.sh_window: Tk = window
        self.sh_window.title('Paper trading')
        window_width: int = self.sh_window.winfo_reqwidth()
        window_height: int = self.sh_window.winfo_reqheight()
        position_right: int = int(self.sh_window.winfo_screenwidth() / 2 - window_width / 2)
        position_down: int = int(self.sh_window.winfo_screenheight() / 2 - window_height / 2)
        self.sh_window.geometry("1000x800+300+100")
        self.sh_window.grid_rowconfigure(0, weight=0)
        self.sh_window.grid_columnconfigure(0, weight=1)
        rh = self.sh_window.winfo_height()
        rw = self.sh_window.winfo_width()
        #self.sh_window.configure(width=1200,height=800)
        #self.sh_window.grid_propagate(0)
        
        pdx = 5
        pdy = 5
        row_idx = 0
        top_frame: Frame = Frame(self.sh_window,width=rw,height=.1*rh)
        #top_frame.pack(anchor='nw',fill='both', expand=True, side=TOP)
        top_frame.grid(row=0,column=0,sticky='nsew')
        #top_frame.grid_rowconfigure(0, weight=0)
        #top_frame.grid_columnconfigure(0, weight=0)
        #top_frame.grid_propagate(1)
        #top_frame.configure(height=500)
        
        var_stock: StringVar = StringVar()
        var_stock.set(" ")
        lbl_stock: Label = Label(top_frame,text='Symbol',justify=LEFT,font=("TkDefaultFont", 10,"bold"),width=10)
        #lbl_stock.pack(anchor=N, expand=False, side=LEFT)
        lbl_stock.grid(row=0,column=0,sticky='nw',padx=pdx,pady=pdy)
        self.combo_box_stock = Combobox(top_frame,width=10,textvariable=var_stock) 
        #self.combo_box_stock.pack(anchor=N, expand=False, side=LEFT)
        self.combo_box_stock.grid(row=0,column=1,sticky='nw',padx=pdx,pady=pdy)
        self.combo_box_stock.configure(state='readonly')
        self.combo_box_stock['values'] = self.indices
        self.combo_box_stock.bind('<<ComboboxSelected>>', self.set_expiry_date)

        date_var_stock: StringVar = StringVar()
        date_var_stock.set(" ")
        lbl_exp_date_stock: Label = Label(top_frame,text='Expiry',justify=LEFT,font=("TkDefaultFont", 10,"bold"),width=10)
        #lbl_exp_date_stock.pack(anchor=N, expand=False, side=LEFT)
        lbl_exp_date_stock.grid(row=1,column=0,sticky=N+S+W,padx=pdx,pady=pdy)
        self.date_combo_box_stock = Combobox(top_frame,width=10,textvariable=date_var_stock) 
        #self.date_combo_box_stock.pack(anchor=N, expand=False, side=LEFT)
        self.date_combo_box_stock.grid(row=1,column=1,sticky=N+S+W,padx=pdx,pady=pdy)
        self.date_combo_box_stock.configure(state='readonly')
        self.date_combo_box_stock.bind('<<ComboboxSelected>>', self.set_expiry_date)
        #
        var_lot_size: StringVar = StringVar()
        var_lot_size.set(" ")
        lbl_lot_size: Label = Label(top_frame,text='Qty',justify=LEFT,font=("TkDefaultFont", 10, "bold"))
        #lbl_lot_size.pack(anchor=N, expand=False, side=LEFT)
        lbl_lot_size.grid(row=0,column=2,sticky=N+S+W,padx=pdx,pady=pdy)
        self.qty_combo_box = Combobox(top_frame,width=10,textvariable=var_lot_size) 
        #self.qty_combo_box.pack(anchor=N, expand=False, side=LEFT)
        self.qty_combo_box.configure(state='readonly')
        self.qty_combo_box.grid(row=0,column=3,sticky=N+S+W,padx=pdx,pady=pdy)
        
        var_vix: StringVar = StringVar()
        var_vix.set(" ")
        lbl_vix: Label = Label(top_frame,text='VIX',justify=LEFT,font=("TkDefaultFont", 10, "bold"))
        #lbl_vix.pack(anchor=N, expand=False, side=LEFT)
        lbl_vix.grid(row=1,column=2,sticky=N+S+W,padx=pdx,pady=pdy)
        self.vix_combo_box = Combobox(top_frame,width=10,textvariable=var_vix) 
        #self.vix_combo_box.pack(anchor=N, expand=False, side=LEFT)
        self.vix_combo_box.grid(row=1,column=3,sticky=N+S+W,padx=pdx,pady=pdy)
        self.vix_combo_box.configure(state='readonly')
        self.vix_combo_box['values'] = list(map(lambda x: x/10.0, range(5, 100, 5)))
        self.vix_combo_box.bind('<<ComboboxSelected>>', self.set_VIX)
        

        self.start_button: Button = tk.Button(top_frame,text='Trade',command=self.main_recursive,width=10,bg='green',fg='white',font=("TkDefaultFont", 10, "bold"))
        #self.start_button.pack(anchor=N, expand=False, side=LEFT)
        self.start_button.grid(row=0,column=4,sticky=N+S+W)#,padx=pdx,pady=pdy)
        self.start_button.configure(state='disabled')
        
        self.import_button: Button = tk.Button(top_frame,text='Manual',command=self.import_iron_condor,width=10,bg='red',fg='white',font=("TkDefaultFont", 10, "bold"))
        #self.import_button.pack(anchor=N, expand=False, side=LEFT)
        self.import_button.grid(row=0,column=5,sticky=N+S+W)#,padx=pdx,pady=pdy)
        self.import_button.configure(state='disabled')
        
        self.load_button: Button = tk.Button(top_frame,text='Load trade',command=self.load_file,width=10,bg='yellow',fg='black',font=("TkDefaultFont", 10, "bold"))
        self.load_button.grid(row=1,column=4,sticky=N+S+W+E)
        self.load_button.configure(state='normal')
        
        self.lbl_nse_con_time: Label = Label(top_frame,text=' ',justify=LEFT,font=("TkDefaultFont", 10, "bold"))
        #self.lbl_nse_con_time.pack(anchor=N, expand=False, side=LEFT)
        self.lbl_nse_con_time.grid(row=0,column=6,sticky=N+S+W+E)
        
        bot_frame: Frame = Frame(self.sh_window,width=1200,height=.3*rh)
        #bot_frame.pack(anchor='nw', fill='both',expand=True, side=TOP)
        bot_frame.grid(row=1,column=0,sticky='nsew')
        #bot_frame.grid_rowconfigure(0, weight=1)
        #bot_frame.grid_columnconfigure(0, weight=1)
        #bot_frame.grid_propagate(0)
        
        self.plot_frame: Frame = Frame(self.sh_window,width=1200, height=.6*rh)
        #self.plot_frame.pack(anchor='nw', fill='both',expand=True, side=TOP)
        self.plot_frame.grid(row=2,column=0,sticky="nsew")
        #self.plot_frame.grid_rowconfigure(0, weight=1)
        #self.plot_frame.grid_columnconfigure(0, weight=1)
        #self.plot_frame.grid_propagate(0)
        
        fig = Figure(figsize = (2, 2), dpi = 200) 
        self.plot1 = fig.add_subplot(111)
        self.plot1.tick_params(axis='both', which='minor', labelsize=8)

        self.canvas = FigureCanvasTkAgg(fig,master = self.plot_frame)
        self.canvas.get_tk_widget().pack(anchor=N,fill='both',expand=True) 
        
        self.NB: Notebook = Notebook(bot_frame)
        self.NB.pack(anchor=N,fill="both", expand=True)
        self.NBF: List[Frame] = []
        self.NBS: List[tksheet.Sheet] = []
        self.NB_DF: List[pd.Dataframe] = []
        
        for strat in enumerate(self.strategies):
            self.NBF.append(Frame(self.NB))
            self.NB.add(self.NBF[-1],text=strat[1])
            sh = tksheet.Sheet(self.NBF[-1], column_width=100, align="center",
                                                  headers = self.sh_cols[strat[0]],
                                                  header_font=("TkDefaultFont", 10, "bold"),
                                                  empty_horizontal=0, empty_vertical=20, header_height=35)
            sh.enable_bindings(
            ("toggle_select", "drag_select", "column_select", "row_select", "column_width_resize",
             "arrowkeys", "right_click_popup_menu", "rc_select", "copy", "select_all"))
            sh.pack(anchor=W,fill="both", expand=True)
            #sh.change_theme("dark")
            self.NBS.append(sh)
Ejemplo n.º 14
0
Archivo: flex.py Proyecto: cpellet/Flex
    def __init__(self):
        tk.Tk.__init__(self)
        self.selectedCell = tk.StringVar()
        self.selectedCellSumMean = tk.StringVar()
        selectedCellLabel = tk.Label(self, textvariable=self.selectedCell)
        selectedCellLabel.grid(row=1, column=0, sticky="se")
        selectedCellSumMeanLabel = tk.Label(
            self, textvariable=self.selectedCellSumMean)
        selectedCellSumMeanLabel.grid(row=1, column=0, sticky="sw")
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)
        self.sheet = tksheet.Sheet(
            self,
            data=[],  # to set sheet data at startup
            total_rows=
            INIT_ROWS,  #if you want to set empty sheet dimensions at startup
            total_columns=
            INIT_COLS,  #if you want to set empty sheet dimensions at startup
            height=500,  # height and width arguments are optional
            width=1200)  # For full startup arguments see DOCUMENTATION.md
        self.sheet.enable_bindings((
            "single_select",  # "single_select" or "toggle_select"
            "drag_select",  # enables shift click selection as well
            "column_drag_and_drop",
            "row_drag_and_drop",
            "column_select",
            "row_select",
            "column_width_resize",
            "double_click_column_resize",
            # "row_width_resize",
            # "column_height_resize",
            "arrowkeys",
            "row_height_resize",
            "double_click_row_resize",
            "right_click_popup_menu",
            "rc_select",
            "rc_insert_column",
            "rc_delete_column",
            "rc_insert_row",
            "rc_delete_row",
            "copy",
            "cut",
            "paste",
            "delete",
            "undo",
            "edit_cell"))
        self.sheet.grid(row=0, column=0, sticky="nswe")
        self.buildMenu()

        # __________ HIGHLIGHT / DEHIGHLIGHT CELLS __________

        #self.sheet.highlight_cells(row=5, column=5, bg="#ed4337", fg="white")
        #self.sheet.highlight_cells(row=5, column=1, bg="#ed4337", fg="white")
        #self.sheet.highlight_cells(row=5, bg="#ed4337", fg="white", canvas="row_index")
        #self.sheet.highlight_cells(column=0, bg="#ed4337", fg="white", canvas="header")

        # __________ DISPLAY SUBSET OF COLUMNS __________

        # self.sheet.display_subset_of_columns(indexes = [3, 1, 2], enable = True) #any order

        # __________ DATA AND DISPLAY DIMENSIONS __________

        # self.sheet.total_rows(4) #will delete rows if set to less than current data rows
        # self.sheet.total_columns(2) #will delete columns if set to less than current data columns
        # self.sheet.sheet_data_dimensions(total_rows = 4, total_columns = 2)
        # self.sheet.sheet_display_dimensions(total_rows = 4, total_columns = 6) #currently resets widths and heights
        # self.sheet.set_sheet_data_and_display_dimensions(total_rows = 4, total_columns = 2) #currently resets widths and heights

        # __________ SETTING OR RESETTING TABLE DATA __________

        # .set_sheet_data() function returns the object you use as argument
        # verify checks if your data is a list of lists, raises error if not
        # self.data = self.sheet.set_sheet_data([[f"Row {r} Column {c}" for c in range(30)] for r in range(2000)], verify = False)

        # __________ SETTING ROW HEIGHTS AND COLUMN WIDTHS __________

        # self.sheet.set_cell_data(0, 0, "\n".join([f"Line {x}" for x in range(500)]))
        # self.sheet.set_column_data(1, ("" for i in range(2000)))
        # self.sheet.row_index((f"Row {r}" for r in range(2000))) #any iterable works
        # self.sheet.row_index("\n".join([f"Line {x}" for x in range(500)]), 2)
        # self.sheet.column_width(column = 0, width = 300)
        # self.sheet.row_height(row = 0, height = 60)
        # self.sheet.set_column_widths([120 for c in range(30)])
        # self.sheet.set_row_heights([30 for r in range(2000)])
        # self.sheet.set_all_column_widths()
        # self.sheet.set_all_row_heights()
        # self.sheet.set_all_cell_sizes_to_text()

        # __________ BINDING A FUNCTION TO USER SELECTS CELL __________

        self.sheet.extra_bindings([
            ("cell_select", self.cell_select),
            ("shift_cell_select", self.shift_select_cells),
            ("drag_select_cells", self.drag_select_cells),
            ("ctrl_a", self.ctrl_a), ("row_select", self.row_select),
            ("shift_row_select", self.shift_select_rows),
            ("drag_select_rows", self.drag_select_rows),
            ("column_select", self.column_select),
            ("shift_column_select", self.shift_select_columns),
            ("drag_select_columns", self.drag_select_columns),
            ("deselect", self.deselect), ("edit_cell", self.edit_cell),
            ("begin_edit_cell", self.edit_cell_begin),
            ("delete_key", self.delk)
        ])

        # self.sheet.extra_bindings([("cell_select", None)]) #unbind cell select
        # self.sheet.extra_bindings("unbind_all") #remove all functions set by extra_bindings()

        self.sheet.bind("<3>", self.rc)
        self.sheet.bind("<BackSpace>", self.delk)