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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
| #coding:utf-8
import matplotlib.gridspec as gridspec
import tkinter as tk
import matplotlib
import matplotlib.pyplot as plt
import math
import os
import numpy as np
from tkinter import Canvas
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
from cycler import cycler
import matplotlib.colors as mcolors
from tkinter import filedialog
from tkinter import ttk
from tkinter import font, colorchooser, filedialog,messagebox
from PIL import Image, ImageTk
matplotlib.use('TkAgg')
#____________different function____________#
def my_plotter(ax, data1, data2, param_dict):
out = ax.plot(data1, data2, **param_dict)
return out
def func_1(event):
event.widget.destroy()
def func_2(event_2):
start_new_file()
def func_3(event_3):
event_3.widget.destroy()
def func_4(event_4):
help_documenting()
def func_5(event_5):
setting_simulation_weather_setting()
def func_6(event_6):
setting_simulation_rocket_setting()
def func_7(event_7):
setting_simulation_viewing_graphics()
def start_new_file():
exec(open("./VisualTracer_Software.py").read())
def file_opening():
app.fileName = open(filedialog.askopenfilename(initialdir="/",
title="Select your file",
filetypes =(("File text","*.txt"),("All file","*.*"))))
os.popen(app.fileName)
#----------------------- toolbar-----------------------#
# window help
def help_documenting():
documenting = tk.Toplevel(app)
documenting.title("Documenting")
documenting.iconbitmap(r"index_FGQ_icon.ico")
documenting.geometry("800x600")
documenting.bind('<Control-q>', func_3) # quit window
lb = tk.Label(documenting, text="In development...")
lb.pack()
# window live graphics
def live_graphics_graphics():
graphics = tk.Toplevel(app)
graphics.title("graphics")
graphics.iconbitmap(r"index_FGQ_icon.ico")
graphics.geometry("800x600")
graphics.bind('<Control-q>', func_3) # quit window
lb = tk.Label(graphics, text="Next update 2.0...")
lb.pack()
# window setting weather
def setting_simulation_weather_setting():
weather_setting = tk.Toplevel(app)
weather_setting.title("weather setting")
weather_setting.iconbitmap(r"index_FGQ_icon.ico")
weather_setting.geometry("800x600")
weather_setting.bind('<Control-q>', func_3) # quit window
lb = tk.Label(weather_setting, text="In development...")
lb.pack()
def setting_simulation_rocket_setting():
rocket_setting = tk.Toplevel(app)
rocket_setting.title("rocket setting")
rocket_setting.iconbitmap(r"index_FGQ_icon.ico")
rocket_setting.geometry("800x600")
rocket_setting.bind('<Control-q>', func_3) # quit window
lb = tk.Label(rocket_setting, text="In development")
def setting_simulation_viewing_graphics():
# Interface viewing graphics
viewing_setting = tk.Toplevel(app)
viewing_setting.title("viewing setting")
viewing_setting.iconbitmap(r"index_FGQ_icon.ico")
viewing_setting.bind('<Control-q>', func_3)
viewing_setting.geometry("1920x1080")
# graphics
x = [1,2,3,4,5,6,7,8,9,10]
y = [1,2,3,9,5,6,7,8,9,10]
f = Figure(figsize=(6, 4), dpi=100)
a_1 = f.add_subplot(221)
a_1.set_title(string_graphic_1.get())
a_1.plot(x,y)
a_1.set_prop_cycle(color=["r"], lw=[1]) # the other color are r,g,b,c,m,y
#____________color board_________________________#
a_1.set_facecolor('#eafff5')
a_1.set_xlabel('time (s)', color='c')
a_1.set_ylabel('voltage (mV)', color='peachpuff')
a_1.plot(x,y, 'xkcd:crimson')
a_1.tick_params(labelcolor='tab:orange')
#_______________________________________________#
a_1.set_xlim(0)
a_1.set_ylim(0)
a_1.set_xticks([1,2,3,4,5,6,7,8,9])
a_1.set_yticks([1,2,3,4,5,6,7,8,9])
a_1.set_xlabel("Time(s)")
a_1.set_ylabel("Altitude(m)")
a_1.yaxis.grid(True)
a_1.xaxis.grid(True)
a_2= f.add_subplot(222)
a_2.set_title(string_graphics_2.get())
a_2.plot(x,y)
a_2.set_xlim(0)
a_2.set_ylim(0)
a_2.set_xticks([1,2,3,4,5,6,7,8,9])
a_2.set_yticks([1,2,3,4,5,6,7,8,9])
a_2.set_xlabel("Time(s)")
a_2.set_ylabel("Velocity(m\s)")
a_2.yaxis.grid(True)
a_2.xaxis.grid(True)
a_3= f.add_subplot(223)
a_3.set_title(string_graphics_3.get())
a_3.plot(x,y)
a_3.set_xlim(0)
a_3.set_ylim(0)
a_3.set_xticks([1,2,3,4,5,6,7,8,9])
a_3.set_yticks([1,2,3,4,5,6,7,8,9])
a_3.set_xlabel("Time(s)")
a_3.set_ylabel("Angle y(°)")
a_3.yaxis.grid(True)
a_3.xaxis.grid(True)
a_4= f.add_subplot(224)
a_4.set_title(string_graphics_4.get())
a_4.plot(x,y)
a_4.set_xlim(0)
a_4.set_ylim(0)
a_4.set_xticks([1,2,3,4,5,6,7,8,9])
a_4.set_yticks([1,2,3,4,5,6,7,8,9])
a_4.set_xlabel("Time(s)")
a_4.set_ylabel("Angle x(°)")
a_4.yaxis.grid(True)
a_4.xaxis.grid(True)
my_plotter(a_1,x,y,{'marker': 'x'})
my_plotter(a_2,x,y,{'marker': 'x'})
my_plotter(a_3,x,y,{'marker': 'x'})
my_plotter(a_4,x,y,{'marker': 'x'})
canvas = FigureCanvasTkAgg(f, viewing_setting)
canvas.draw()
canvas.get_tk_widget().place(x=500, y =100 ,width=800, height=800)
toolbar = NavigationToolbar2Tk(canvas, viewing_setting)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
def Information_about_VisualTracer():
messagebox.showinfo("Visual Tracer", "Name: Visual Tracer ©\nVersion: 1.0\nOS: Windows10\nCreation year: 2020")
#____________setting launcher____________#
app = tk.Tk()
app.title("Visual Tracer Launcher")
app.iconbitmap(r"index_FGQ_icon.ico")
screen_X = int(app.winfo_screenwidth())
screen_Y = int(app.winfo_screenheight())
window_x = 1920
window_y = 1080
posX = (screen_X // 2) - (window_x //2)
posY = (screen_Y //2) - (window_y //2)
geo = "{}x{}+{}+{}".format(window_x, window_y, posX, posY)
app.geometry(geo)
# keyboard shortcut interface
app.bind('<Control-q>', func_1) # quit Visual Tracer Software
app.bind('<Control-o>', func_2) # create new page Visual Tracer Software
app.bind('<Control-d>', func_4) # open documenting window
app.bind('<Control-w>', func_5) # open weather window
app.bind('<Control-r>', func_6) # open rocket window
app.bind('<Control-v>', func_7) # open viewing window
# setting toolbar
mainmenu = tk.Menu()
File_menu = tk.Menu(mainmenu, tearoff=0)
edit_menu = tk.Menu(mainmenu, tearoff=0)
setting_simulation = tk.Menu(mainmenu, tearoff=0)
Live_menu = tk.Menu(mainmenu, tearoff=0)
fifth_menu = tk.Menu(mainmenu, tearoff=0)
# file menu icons
Open_File_icon = tk.PhotoImage(file="text-file_icon-icons.com_73377.png")
Open_New_File = tk.PhotoImage(file="open-file-button.png")
Quit_icon = tk.PhotoImage(file="4213459-common-door-exit-logout-out-signout_115411(1).png")
Save_as_icon = tk.PhotoImage(file="seo-social-web-network-internet_273_icon-icons.com_61489(1).png")
# edit menu icons
Copy_icon = tk.PhotoImage(file="copy-two-paper-sheets-interface-symbol_icon-icons.com_73283(1)(1).png")
Paste_icon = tk.PhotoImage(file="wondicon-ui-free-file_111223(1).png")
Cut_icon = tk.PhotoImage(file="fullcut_cut_scissors_4720(1).png")
Select_all_icon = tk.PhotoImage(file="select_icon-icons.com_48233(1).png")
Cancel_icon = tk.PhotoImage(file="ic-back_97586(1).png")
Create_new_window_icon = tk.PhotoImage(file="-create-new-folder_90671(1).png")
Quit_icon = tk.PhotoImage(file="4213459-common-door-exit-logout-out-signout_115411(1).png")
Other_shortcut_icon = tk.PhotoImage(file="settinglines_87251(1).png")
# setting simulation icons
weather_setting_icon = tk.PhotoImage(file="weather_variable_fullmoon_39769(1).png")
rocket_setting_icon= tk.PhotoImage(file="1492719123-rocket_83625(1).png")
viewing_setting_icon = tk.PhotoImage(file="1491254371-settinggearprocessengineering_82943(1).png")
# live graphic icon
Live_graphic_icon = tk.PhotoImage(file="live-tv_118973(1).png")
# Help icons
Documenting_icon = tk.PhotoImage(file="DocumentEdit_40924(1).png")
About_icon = tk.PhotoImage(file="info_about_information_icon_132735(1).png")
mainmenu.add_cascade(label="File", menu=File_menu)
mainmenu.add_cascade(label="Edition", menu=edit_menu)
mainmenu.add_cascade(label="setting simulation", menu=setting_simulation)
mainmenu.add_cascade(label="live graphics", menu=Live_menu)
mainmenu.add_cascade(label="Help", menu=fifth_menu)
File_menu.add_command(label="Open file", command=file_opening, image=Open_File_icon, compound=tk.LEFT)
File_menu.add_command(label="Open new file", command=start_new_file, image=Open_New_File, compound=tk.LEFT)
File_menu.add_command(label="Quit", command=app.quit, image=Quit_icon, compound=tk.LEFT)
File_menu.add_command(label="Save as",image=Save_as_icon, compound=tk.LEFT)
edit_menu.add_command(label="Copy", accelerator="Ctrl+C",image=Copy_icon,compound=tk.LEFT )
edit_menu.add_command(label="Paste", accelerator="Ctrl+V",image=Paste_icon,compound=tk.LEFT)
edit_menu.add_command(label="Cut", accelerator="Ctrl+X",image=Cut_icon,compound=tk.LEFT)
edit_menu.add_command(label="Select all", accelerator="Ctrl+A",image=Select_all_icon,compound=tk.LEFT)
edit_menu.add_command(label="Cancel", accelerator="Ctrl+Z",image=Cancel_icon,compound=tk.LEFT)
edit_menu.add_separator()
edit_menu.add_command(label="Create new window",accelerator="Ctrl+O",image=Create_new_window_icon,compound=tk.LEFT)
edit_menu.add_command(label="Quit",accelerator="Ctrl+Q",image=Quit_icon,compound=tk.LEFT)
edit_menu.add_command(label="Other shortcut", command=help_documenting,image=Other_shortcut_icon,compound=tk.LEFT)
setting_simulation.add_command(label="weather setting", command=setting_simulation_weather_setting, image=weather_setting_icon, compound=tk.LEFT)
setting_simulation.add_command(label="rocket setting", command=setting_simulation_rocket_setting, image=rocket_setting_icon, compound=tk.LEFT)
setting_simulation.add_command(label="viewing graphics", command=setting_simulation_viewing_graphics, image=viewing_setting_icon, compound=tk.LEFT)
Live_menu.add_command(label="graphics", command=live_graphics_graphics, image=Live_graphic_icon, compound=tk.LEFT)
fifth_menu.add_command(label="Documenting", command=help_documenting, image=Documenting_icon, compound=tk.LEFT)
fifth_menu.add_command(label="About", command=Information_about_VisualTracer,image=About_icon, compound=tk.LEFT)
c = Canvas(app, height=1080, width=1920, bg="white")
c.create_text("250","10", text="Setting", font="Arial 10")
boutton_save = tk.Button(c, text="OK", command=setting_simulation_viewing_graphics)
boutton_save.place(x=900, y=950, width="200", height="20")
string_graphic_1 = tk.StringVar()
graphics_1 = tk.Entry(c, textvariable=string_graphic_1)
graphics_1.configure(font=("Impact", 12))
graphics_1.place(x=200,y=800)
lb= tk.Label(c, text="Graphic title 1 :")
lb.place(x=100, y=798, width="100")
string_graphics_2 = tk.StringVar()
graphics_2 = tk.Entry(c, textvariable=string_graphics_2)
graphics_2.place(x=600, y=800)
lb_graphic_2= tk.Label(c, text="Graphic title 2 :")
lb_graphic_2.place(x=500, y=798, width="100")
string_graphics_3 = tk.StringVar()
graphics_3 = tk.Entry(c, textvariable=string_graphics_3)
graphics_3.place(x=1000, y=800)
lb_graphic_3= tk.Label(c, text="Graphic title 3 :")
lb_graphic_3.place(x=900, y=798, width="100")
string_graphics_4 = tk.StringVar()
graphics_4 = tk.Entry(c, textvariable=string_graphics_4)
graphics_4.place(x=1400, y=800)
lb_graphic_4= tk.Label(c, text="Graphic title 4 :")
lb_graphic_4.place(x=1300, y=798, width="100")
tool_bar = ttk.Label(c)
tool_bar.place(x=0, y=0)
font_tuple = tk.font.families()
font_family = tk.StringVar
font_box = ttk.Combobox(tool_bar, width=30, textvariable=font_family, state="readonly")
font_box["values"]= font_tuple
font_box.current(font_tuple.index("Arial"))
font_box.grid(row=0, column=0, padx=5)
# size box
size_var = tk.IntVar()
font_size = ttk.Combobox(tool_bar, width=14, textvariable = size_var, state='readonly')
font_size['values'] = tuple(range(8,81))
font_size.current(4)
font_size.grid(row=0, column=1, padx=5)
# bold button
bold_icon = tk.PhotoImage(file='bold.png')
bold_btn = ttk.Button(tool_bar, image=bold_icon)
bold_btn.grid(row=0, column=2, padx=5)
# italic button
italic_icon = tk.PhotoImage(file='italic.png')
italic_btn = ttk.Button(tool_bar, image=italic_icon)
italic_btn.grid(row=0, column=3, padx=5)
# underline button
underline_icon = tk.PhotoImage(file='underline.png')
underline_btn = ttk.Button(tool_bar, image = underline_icon)
underline_btn.grid(row = 0, column=4, padx=5)
# font color button
font_color_icon = tk.PhotoImage(file='font_color.png')
font_color_btn = ttk.Button(tool_bar, image=font_color_icon)
font_color_btn.grid(row=0, column=5,padx=5)
# align left
align_left_icon = tk.PhotoImage(file='align_left.png')
align_left_btn = ttk.Button(tool_bar, image=align_left_icon)
align_left_btn.grid(row=0, column=6, padx=5)
# align center
align_center_icon = tk.PhotoImage(file='align_center.png')
align_center_btn = ttk.Button(tool_bar, image=align_center_icon)
align_center_btn.grid(row=0, column=7, padx=5)
# align right
align_right_icon = tk.PhotoImage(file='align_right.png')
align_right_btn = ttk.Button(tool_bar, image=align_right_icon)
align_right_btn.grid(row=0, column=8, padx=5)
# font family and font size functionality
c.pack()
bou_4 = tk.Button(app, text="Graphical setting of the image", command=setting_simulation_rocket_setting)
bou_4.pack()
# different loop
app.config(menu=mainmenu)
app.mainloop() |
Partager