Hi Everyone. Consider this part two after solving part one of my output window issie
basically 7zip i needed to output its text to a output window i had created inside my main menu where the button "backup" exists.
The window within the window code looks like this.
outputLabel = Label(root,text="7Zip Output Window")
outputLabel.place(x=500,y=425)
outputWindow = Text(root)
outputWindow.config(relief=SUNKEN, bg='beige',width=51,height=17)
outputWindow.place(x=350,y=130)
and when you click the backup button this piece of code executes
def picbackup():
source = ['-ir!"%USERPROFILE%\*.bmp"', '-ir!"%USERPROFILE%\*.tif"', '-ir!"%USERPROFILE%\\*.gif"']
target_dir = '.\\'
today = time.strftime('%d_%m_%Y')
target = '.\\Backup\Pictures_' + today + '.zip'
zip = os.popen ("D:\\Backup\\7Zip\\7z.exe a -bd -ssw {0} {1}".format(target, ' '.join(source)))
shellOutput = zip.read()
zip.close()
outputWindow.delete('1.0',END)
outputWindow.insert('1.0',shellOutput)
if os.system(zip_command) == 0:
# can a progress bar be implemented or EBC anim ?????
print('Successful backup to', target)
else:
print('Backup FAILED')
ok ... this is great cause it works ... but i have niggly issues i would like to solve.
1. The output only appears AFTER 7zip has completed. (i would like to see it happen in real time
2. No scroll bars (i have extensive researched this and found when i try to put the working source code in .. it puts scroll bars on the ENTIRE MAIN MENE (root?) window .. NOT the small output window.
3. the output that is show is showing the TOP of the output and not the bottom .... ii do have code for this embedded in my scroll bar code BUT like above ... the scroll bars are attaching to the wrong window.
If anyone can help me .. the code i have been using to help me is here. this works great cause it has scrolls, shows the bottom of the text instantly ... i'm not sure how it works in a live continous output situation but i guess we'll see.
# searching a long text for a string and scrolling to it
# use ctrl+c to copy, ctrl+x to cut selected text,
# ctrl+v to paste, and ctrl+/ to select all
import tkinter as tk
def display(data):
"""creates a text display area with a vertical scrollbar"""
scrollbar = tk.Scrollbar(root)
text1 = tk.Text(root, yscrollcommand=scrollbar.set)
text1.insert(0.0, data)
scrollbar.config(command=text1.yview)
scrollbar.pack(side='right', fill='y')
text1.pack(side='left', expand=0, fill='both')
# could bring the search string in from a listbox selection
pattern = "Chapter 3"
# line.char(lines start at 1, characters at 0)
start = "1.0"
# returns eg. "31.0" --> line 31, character 0
index = text1.search(pattern, start)
# <strong class="highlight">scroll</strong> text until index line is visible
# might move to the top line of text field
text1.see(index)
root = tk.Tk()
str1 = """\
Chapter 1
.
.
.
.
.
.
.
Chapter 2
.
.
.
.
.
.
.
.
Chapter 3
.
.
.
.
.
.
.
.
The End
"""
display(str1)
root.mainloop()
Thankyou for your time ... and so far .. thansk to everyone as i have gained heaps using these forums to seek out answers, snippet code .. all great stuff.