1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| from configparser import ConfigParser
import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter.ttk import *
from tkinter import font
from tkinter import Listbox
import ftplib
import os
from datetime import datetime, timedelta
from pytz import timezone
import string
import array
from io import BytesIO
import numpy as np
from mpl_toolkits.axes_grid1 import host_subplot
import matplotlib.pyplot as plt
from collections import Counter
from tkinter import messagebox
#Graphical Interface test
class Application(ttk.Frame):
def __init__(self, main_window):
super().__init__(main_window)
main_window.title("MyFirtsInterfaceWithPython3.x")
#Size of my window interface
w = 1300
h = 700
ws = main_window.winfo_screenwidth()
hs = main_window.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
main_window.geometry('%dx%d+%d+%d' % (w, h, x, y))
self.GraphicalInterface()
def GraphicalInterface(self):
#Define font
Myfont=font.Font(main_window, family='Courier new', size='10')
labelSelectline = tk.Label(main_window, text="Select a line:", anchor="w", font=Myfont)
labelSelectline.grid(row=0, column=0, padx=10, sticky=NW)
COMBOBOX_LINE = ttk.Combobox(main_window, values=("A", "B", "C", "D"), state='readonly', font=Myfont)
COMBOBOX_LINE.grid(row=1, column=0, padx=10, sticky=NW)
labelSelectCell = tk.Label(main_window, text="Select a cell:", anchor="w", font=Myfont)
labelSelectCell.grid(row=2, column=0, padx=10, sticky=NW)
Cell_listbox = Listbox(main_window, font=Myfont, width=22)
Cell_listbox.grid(row=3, column=0, padx=10, sticky=NW)
#Create a vertical scrollbar to the right of the listbox
yscroll = tk.Scrollbar(command=Cell_listbox.yview, orient=tk.VERTICAL)
yscroll.grid(row=3, column=0, padx=10, pady=10, sticky=NS+NE)
Cell_listbox.configure(yscrollcommand=yscroll.set)
#Filling
i=0
while i<30:
Cell_listbox.insert(END, i)
i+=1
#ListView
tree = ttk.Treeview(main_window)
tree.grid(row=4, column=0, sticky=EW, padx=10, pady=10)
style = ttk.Style()
style.configure("Treeview.Heading", font=('Courier new', 10))
style.configure("Treeview", font=('Courier new', 10))
tree["columns"] = ("Column_1","Column_2", "Column_3", "Column_4")
tree.column("#0", width=230, minwidth=0, stretch=tk.YES)
tree.column("Column_1", width=175, minwidth=0, stretch=tk.YES)
tree.column("Column_2", width=70, minwidth=0, stretch=tk.YES)
tree.column("Column_3", width=450, minwidth=0, stretch=tk.YES)
tree.column("Column_4", width=150, minwidth=0, stretch=tk.YES)
tree.heading("#0", text="Nom")
tree.heading("Column_1", text="Date")
tree.heading("Column_2", text="Taille")
tree.heading("Column_3", text="Chemin")
tree.heading("Column_4", text="Port FTP")
#Create a vertical scrollbar to the right of the ListView (tree)
tree_yscroll = tk.Scrollbar(command=tree.yview, orient=tk.VERTICAL)
tree_yscroll.grid(row=4, column=0, pady=10, sticky=NS+NE)
tree.configure(yscrollcommand=yscroll.set)
main_window = tk.Tk()
app = Application(main_window)
app.mainloop() |
Partager