Question

In: Computer Science

Please enter flowchart. Thank you! from tkinter import * from tkinter.scrolledtext import ScrolledText #method to open...

Please enter flowchart. Thank you!

from tkinter import *
from tkinter.scrolledtext import ScrolledText

#method to open file and load contents into text field
def open_file():
#fetching file name from filenamevar StringVar
filename=filenamevar.get()
try:
#opening file in read mode
file=open(filename,'r')
#reading text
text=file.read()
#replacing current text in textField to read text
textField.replace("1.0",END,text)
#closing file
file.close()
except:
#displaying error message in textField
textField.replace("1.0", END, 'File not found!')


#method to save current contents of file into file mentioned in file name entry field
def save_file():
#fetching file name
filename=filenamevar.get()
try:
#opening file in append mode
file=open(filename,'a')
#getting current text in textField
text=textField.get("1.0",END)
#writing to file
file.write(text)
#saving and closing file
file.close()
#displaying success message in textField
textField.replace("1.0",END,"Saved!")
except:
#displaying error message in textField
textField.replace("1.0", END, 'Error while saving!')


#creating a root window, setting title
root=Tk()
root.title('GUI Writer')


#creating a StringVar so it can be linked to an entry field
filenamevar=StringVar()

#creating and adding a label to the root, using grid geometry, sticky='W' aligns west
Label(root,text='File name: ').grid(row=0,column=0, sticky='W')
#creating Entry, linking filenamevar as textvariable. so filenamevar can get/set
#values of entry field, sticky='EW' stretches field to fit the column
Entry(root,textvariable=filenamevar).grid(row=0,column=1,columnspan=2, sticky='EW')

#another label for "File contents:"
Label(root,text='File contents: ').grid(row=1,column=0, sticky='W')

#a scrolledtext for displaying text
textField=ScrolledText(root)
#adding to root on row 2, column 0, occupying width of 4 columns and height of 4 rows
#using a padding of 10 around margins
textField.grid(row=2,column=0, columnspan=4, rowspan=4,padx=10,pady=10)

#creating open and save buttons, adding command to call open_file() and save_file() methods
#respectively, for opening and saving files
Button(root,text='Open', command=open_file).grid(row=6,column=2, sticky='EW')
Button(root,text='Save', command=save_file).grid(row=6,column=3, sticky='EW')

#staying until user closes the window
root.mainloop()

Solutions

Expert Solution

There have been many flowcharts for many events.

Flowchart Symbols Meaning


Related Solutions

Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import java.util.Scanner; ;//import Scanner to take input from user public class TestScore {    @SuppressWarnings("resource")    public static void main(String[] args) throws ScoreException {//main method may throw Score exception        int [] arr = new int [5]; //creating an integer array for student id        arr[0] = 20025; //assigning id for each student        arr[1] = 20026;        arr[2] = 20027;...
Please can I kindly get a flowchart for this java code. Thank you. //import the required...
Please can I kindly get a flowchart for this java code. Thank you. //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in));...
Convert from python 2 to 3 from Tkinter import * # the blueprint for a room...
Convert from python 2 to 3 from Tkinter import * # the blueprint for a room class Room(object): # the constructor def __init__(self,name,image): # rooms have a name, exits (e.g., south), exit locations (e.g., to the south is room n), # items (e.g., table), item descriptions (for each item), and grabbables (things that can # be taken and put into the inventory) self.name = name self.image = image self.exits = {} self.items = {} self.grabbables = [] # getters and...
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from...
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money =...
You have decided to open a business. What ownership method will you use? Please make sure...
You have decided to open a business. What ownership method will you use? Please make sure to include three points to support your decision.
Please based on my python code. do the following steps: thank you Develop a method build_bst...
Please based on my python code. do the following steps: thank you Develop a method build_bst which takes a list of data (example: [6, 2, 4, 22, 34, 9, 6, 67, 42, 55, 70, 120, 99, 200]) and builds a binary search tree full of Node objects appropriately arranged. Test your build_bst with different sets of inputs similar to the example provided above. Show 3 different examples. Choose 1 example data.  Develop a function to remove a node from a bst...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a series of string values into a list. When the user enters the string ‘done’, stop prompting for values. Once the user is done entering strings, create a new list containing a palindrome by combining the original list with the content of the original list in a reversed order. Sample interaction: Enter string: My Enter string: name Enter string: is Enter string: Sue Enter string:...
Please don't copy and paste from the internet. Thank you - What event will cause the...
Please don't copy and paste from the internet. Thank you - What event will cause the sender to initiate fast retransmit when using TCP? - Describe briefly the relationship between the round trip time (RTT) observed between a sender and a receiver and the retransmit timer used in TCP - Describe briefly the basic difference in service provided by an email server using POP3 protocol compared to an email server using IMAP protocol. Please don't copy and paste from the...
Please completely explain consumer and producer surplus that results from an auction. Thank you :)
Please completely explain consumer and producer surplus that results from an auction. Thank you :)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT