Hello everyone!
So, I’m working on Linux Ubuntu 12.04 and trying to make a GUI which -
-
asks the user to select the desired file using FileDialog
-
then the user clicks on a button which runs a shellscript on the terminal which determines the type of file and what kind of compression would be best for it and then compresses it.
So, I have my shellscript ready and it works perfectly. The trouble is with the GUI ofcourse!
Here’s what I’ve done till now -
import wx
import wx.lib.sized_controls as sc
import sys, subprocess, xdg, os
class abc(sc.SizedFrame):
def __init__(self, parent, id):
super(abc, self).__init__(parent, id, 'Frame aka window')
cpane = self.GetContentsPane()
fileselect
= wx.FileDialog(self, message=‘Choose file to open’, defaultDir=wx.GetHomeDir(), defaultFile=‘evaluation.doc’, style=wx.FD_OPEN)
if fileselect.ShowModal() == wx.ID_OK:
fileName = fileselect.GetPath()
fileselect.Destroy()
button = wx.Button(cpane, label="script")
self.Bind(wx.EVT_BUTTON, self.button1, button)
self.Bind(wx.EVT_CLOSE, self.closewindow)
def button1(self,event):
print os.system('inputscript')
def closewindow(self, event):
self.Destroy()
if name == ‘main’:
import wx.lib.mixins.inspection as wit
app = wit.InspectableApp()
frame = abc(parent=None, id=-1)
frame.Show()
app.MainLoop()
Right now, what I do in my script is I ask the user to enter the file path, then change directory and then
enter the file name. However, I would like this part to be done by the GUI. So, is there a way that the fileName retrieved by the GUI using FileDialog can be passed as an input to the script?
I’ve attached my script alongwith, incase you would like to see it.
P.S. - new to wxpython. So please reply in detail!
Thanks!
script.txt (2.15 KB)