10 Commits
Author SHA1 Message Date
gooneybird47 26e19a8108 First test of a windows .exe file.
First test of a windows .exe file.
2021-05-08 22:55:51 +01:00
gooneybird47 97ef58701a Update README.md 2021-04-25 11:31:02 +01:00
gooneybird47 5b84c47966 Update screenshot.jpg 2021-04-25 11:15:05 +01:00
gooneybird47 54443957c1 Update Traffic_Creator.py
Minor changes to button placement and split flight section into two separate flights.
2021-04-24 19:46:43 +01:00
gooneybird47 907fdfff26 Update README.md 2021-01-02 21:26:00 +00:00
Brett Harrison e6535614dc Update README.md 2021-01-02 20:55:58 +00:00
Brett Harrison 3d33174d7b Update README.md 2021-01-02 20:52:08 +00:00
gooneybird47 a68deec30f Readme created
Readme created
2021-01-02 20:50:04 +00:00
gooneybird47 9bb2ccac7c Screenshot Added
Screenshot Added
2021-01-02 16:15:41 +00:00
gooneybird47 a0ec2fc44e Update Traffic_Creator.py
Minor text alignment
2020-12-31 12:35:53 +00:00
6 changed files with 103 additions and 38 deletions
+45
View File
@@ -0,0 +1,45 @@
## AI Traffic Creator For FlightGear
###A simple Ai traffic creator for FlightGear flight simulator
### Requirements: Python 3 (written in 3.8)
![Screenshot](screenshot/screenshot.jpg)
I believe Linux and Mac already have Python installed by default but windows does not so it will need to be installed if you don't already have it.
The "Traffic_Creator.py" and "traffic_test.xml" files should be extracted to any directory that has read/write permissions.
Traffic_Creator.py can be run either through an IDE or directly from the directory via the command line/terminal by typing "python3 Traffic_Creator.py" without the quotes.
In windows you can open the terminal from the directory the files are in by clicking in the address bar and typing cmd then enter.
**See bottom of this text for a Windows Executable.**
The program should be self explanatory if you have delt with traffic files before but if not I suggest reading up about them on the Wiki first. -
[Wiki.flightgear](http://wiki.flightgear.org/AI_Traffic) (link also in program).
You can create as many aircraft and flights as you wish by filling in the details then pressing the "Create Aircraft Section" then each "Create Flight Section", this process can be repeated as often as you like but remember to alter the relevant details so you don't end up with duplicate flights. Comments can be added anytime they are required.
**Do not close the program until you have finished all tasks and saved the file as this will wipe all data.** Saving the file will automatically close the program.
All you need to enter is the actual text not the .xml tags they will be automatically entered when you save the file.
When finished save the file with the name of your choice, all being well it can be copied straight into your AI/Traffic folder and ready for use.
This is not an xml editor, it can not edit traffic files, I created it to quickly write test or local files so it's not really a program for writing or editing airline schedules.
### Windows Executable
First test of a windows .exe file.
In the "windows_64" folder is a zip file (Traffic_Creator.zip) extract the contents of the zip into a folder that has *write access* and run the "Traffic_Creator.exe" file.
**This has been tested on several windows 10 computers with no problems but I believe it only runs on 64 bit machines.**
### Disclaimer
This is my first Python program so any errors and bugs are entirely down to me. ;)
Written on windows 10 in PyCharm and tested with Linux Mint in Virtualbox with no problems.
+58 -38
View File
@@ -2,9 +2,7 @@ import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from tkinter import messagebox
# from tkinter.filedialog import askopenfile
import webbrowser
# import os
import sys
tg = ['<?xml version="1.0"?>', '<trafficlist>', '</trafficlist>', ' <aircraft>', ' </aircraft>',
@@ -26,7 +24,7 @@ open("traffic_test.xml", "w").close()
root = tk.Tk()
root.geometry('1000x768')
root.title('AI Traffic File Creator For FlightGear')
root.title('AI Traffic File Creator For FlightGear - Author Brett Harrison (gooneybird)')
# Redirect Print To File
@@ -34,13 +32,13 @@ sys.stdout = open('traffic_test.xml', 'a')
# Button click Counters
count_aircraft, count_flight = 0, 0
count_comment, count_aircraft, count_outbound_flight, count_return_flight = 0, 0, 0, 0
# close window
def on_closing():
if messagebox.askokcancel("Quit", "Do you want to quit?"):
if messagebox.askokcancel("Quit", "Do you want to quit?\n All data will be lost!"):
root.destroy()
@@ -52,13 +50,6 @@ root.protocol("WM_DELETE_WINDOW", on_closing)
def close_output():
sys.stdout.close()
# ("traffic_test.xml").close
# if sys.platform == 'linux2':
# subprocess.call(["xdg-open", 'traffic_test.xml'])
# else:
# os.startfile('traffic_test.xml')
with open("traffic_test.xml", 'r+') as finp:
outp = finp.read()
out_all = '<?xml version="1.0"?>\n' + '<trafficlist>\n' + outp + '</trafficlist>'
@@ -80,9 +71,9 @@ def close_output():
txt_label = tk.Label(root, text='If you have never created a traffic before or unsure how to please refer to the Wiki\n'
'you can get there by pressing the "Wiki Link" button above.\n\n'
'Fill in all the sections then first press the "Create Aircraft Section" button\n'
'followed by the "Create Flight Section" button, this will create one\n'
'you can get there by pressing the "Wiki Link" button below.\n\n'
'Fill in all the sections then first press the "Create Aircraft" button\n'
'followed by the "Create Flight" buttons, this will create one\n'
'outbound and return flight for one aircraft. More aircraft and flights can be added\n'
'to the file by altering the required details and pressing the aircraft/flight\n'
'buttons again for each set of data before saving the file.\n\n '
@@ -90,14 +81,23 @@ txt_label = tk.Label(root, text='If you have never created a traffic before or u
'This program is designed to create small test or local traffic files '
'and cannot be used to\n'
'edit them, that is best done in a dedicated xml editor \n\n'
'Be warned,If you exit the program without saving all data will be lost.',
'Be warned,If you exit the program without saving all data will be lost. \n\n',
font=('Arial', 10), bg='powder blue', anchor="w", padx=10, justify='left')
txt_label.grid(row=16, rowspan=9, column=0, columnspan=3)
# Define Comment
def add_comment():
print('<!-- ' + comment.get() + ' -->')
# Count Comment Button clicks
global count_comment
count_comment = count_comment + 1
comment_created.configure(text=f'Comment Created = {count_comment}', font=('Arial', 10))
# Define Aircraft
@@ -140,9 +140,11 @@ def mod():
aircraft_created.configure(text=f'Aircraft Created = {count_aircraft}', font=('Arial', 10))
# Define Flight
# Define Flights
def flt():
# Outbound Flight
def outbound_flt():
# calsig = f1.get()
# reqair = f2.get()
# fltrrule = f3.get()
@@ -169,8 +171,18 @@ def flt():
print(tg[45] + f9.get() + tg[46])
print(tg[30])
# Return flight
# Count Outbound Flight Button clicks
global count_outbound_flight
count_outbound_flight = count_outbound_flight + 1
outbound_flights_created.configure(text=f'Outbound Flights Created = {count_outbound_flight}', font=('Arial', 10))
# Return Flight
def return_flt():
# calsig_r = rf1.get()
# reqair_r = rf2.get()
# fltrrule_r = rf3.get()
@@ -197,13 +209,13 @@ def flt():
print(tg[45] + rf9.get() + tg[46])
print(tg[30])
# Count Flight Button clicks
# Count Return Flight Button clicks
global count_flight
global count_return_flight
count_flight = count_flight + 1
count_return_flight = count_return_flight + 1
flights_created.configure(text=f'Flights Created = {count_flight}', font=('Arial', 10))
return_flights_created.configure(text=f'Return Flights Created = {count_return_flight}', font=('Arial', 10))
# text variables
@@ -303,12 +315,12 @@ m12.current(0)
# Create Aircraft section button
but_e1 = tk.Button(root, font=('Arial', 10), text='1 - Create Aircraft section', command=mod)
but_e1 = tk.Button(root, font=('Arial', 10), text='1 - Create Aircraft', command=mod)
but_e1.grid(row=6, column=2)
# Set Up Flight
# Set Up Outbound Flight
flight_label = tk.Label(root, text='Flight Selection', font=('Arial', 12, 'bold'), width='20', fg='blue')
flight_label = tk.Label(root, text='Outbound Flight', font=('Arial', 12, 'bold'), width='20', fg='blue')
flight_label.grid(row=1, column=5)
f1_label = tk.Label(root, text='Call Sign', font=('Arial', 10), width='20', anchor="e")
@@ -357,10 +369,10 @@ f9_label.grid(row=11, column=4)
f9 = tk.Entry(root, font=('Arial', 10))
f9.grid(row=11, column=5, padx=5, pady=5)
# Return Flight
# Set Up Return Flight
returnflight_label = tk.Label(root, text='Return Flight', font=('Arial', 10, 'bold'))
returnflight_label.grid(row=12, column=4, columnspan=2, padx=5, pady=5)
returnflight_label = tk.Label(root, text='Return Flight', font=('Arial', 12, 'bold'), width='20', fg='blue')
returnflight_label.grid(row=12, column=5, columnspan=2, padx=5, pady=5)
rf1_label = tk.Label(root, text='Call Sign', font=('Arial', 10), width='20', anchor="e")
rf1_label.grid(row=13, column=4)
@@ -408,19 +420,27 @@ rf9_label.grid(row=21, column=4)
rf9 = tk.Entry(root, font=('Arial', 10))
rf9.grid(row=21, column=5, padx=5, pady=5)
# Create Flight Section
# Create Flight Sections
but_e2 = tk.Button(root, font=('Arial', 10), text='2 - Create Flight section', command=flt)
but_e2.grid(row=9, column=2)
but_e2 = tk.Button(root, font=('Arial', 10), text='2 - Create Outbound Flight', command=outbound_flt)
but_e2.grid(row=8, column=2)
# Status Bar - Number Of Aircraft and Flights created
but_e3 = tk.Button(root, font=('Arial', 10), text='3 - Create Return Flight', command=return_flt)
but_e3.grid(row=10, column=2)
# Number Of Comments, Aircraft and Flights created
comment_created = tk.Label(root, fg='red')
comment_created.grid(row=5, column=2)
aircraft_created = tk.Label(root, fg='red')
aircraft_created.grid(row=7, column=2)
flights_created = tk.Label(root, fg='red')
flights_created.grid(row=10, column=2)
outbound_flights_created = tk.Label(root, fg='red')
outbound_flights_created.grid(row=9, column=2)
return_flights_created = tk.Label(root, fg='red')
return_flights_created.grid(row=11, column=2)
# Wiki Link
@@ -433,12 +453,12 @@ def openweb():
webbrowser.open(wiki_url, new=new)
but_wiki = tk.Button(root, font=('Arial', 10), text='Wiki Link', command=openweb)
but_wiki.grid(row=12, column=2)
but_wiki = tk.Button(root, font=('Arial', 12, 'bold'), width='10', fg='green', text='Wiki Link', command=openweb)
but_wiki.grid(row=27, column=1)
# Close Button
but_close = tk.Button(root, text='Save And Exit', command=close_output)
but_close = tk.Button(root, text='Save And Exit', fg='blue', font="Helvetica 12 bold", command=close_output)
but_close.grid(row=14, column=2)
root.mainloop()
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File
Binary file not shown.