Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm a Python beginner, I installed quickly, I wrote a "quickly tutorial" in terminal and I did all the steps before at:

"However, the application is not complete. There are a few things left for you to do:"

All the next steps aren't finished yet because when I use open dialog and select one of the files saved, the content of the file isn't showed on "textview1", Why? Only is deleted the content written. Before if was used without dialog works great.

SaveDialog.py work great.

-def on_mnu_new_activate(self, widget, data=None) don't work neither.

-If I use the bold lines by the others don't work.

###def open_file(self, widget, data=None):
def on_mnu_open_activate(self, widget, data=None):

###def save_file(self, widget, data=None):
def on_mnu_save_activate(self, widget, data=None):

To view the code, go to the link above, unrar the archive, install "quickly" if you don't have it yet, place inside on jotty directory, then put "quickly run", "quickly edit", "quickly design", depending what do you want to do.

Code - problematic code with OpenDialog implemented.

Code-part1 - works OK, but without OpenDialog.

Acces to the two codes here

I need principally that OpenDialog function work great.

ADVANCE -> Go to the last message here

share|improve this question
add comment

2 Answers

im use

def on_openclicked(self, widget):
    dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN,(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
    dialog.set_default_size(100, 50)

    self.add_filters(dialog)

    response = dialog.run()
    if response == Gtk.ResponseType.OK:
        print "Open clicked"
        print "File selected: " + dialog.get_filename()
    elif response == Gtk.ResponseType.CANCEL:
        print "Cancel clicked"

    dialog.destroy()

def add_filters(self, dialog):

    filter_py = Gtk.FileFilter()
    filter_py.set_name("Text files")
    filter_py.add_mime_type("text/plain")
    dialog.add_filter(filter_py)

    filter_any = Gtk.FileFilter()
    filter_any.set_name("Any files")
    filter_any.add_pattern("*")
    dialog.add_filter(filter_any)
share|improve this answer
add comment

Go to your OpenDialog.py and in the @property selected_file section change the returned row to File.

share|improve this answer
    
Why the -1 Rating?? –  Dai Trying Feb 24 at 10:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.