basic code of what I am doing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexnb

    basic code of what I am doing


    Okay, so I wrote some code of basically what I will be doing, only with
    exactly what I need for this part of the program but here you go:

    [code]

    from Tkinter import*
    import os

    class myApp:
    def __init__(self, parent):
    self.parent = parent

    self.baseContai ner = Frame(self.pare nt)
    self.baseContai ner.pack()

    self.e = Entry(self.base Container)
    self.e.bind("<R eturn>", self.entryEnter )
    self.e.pack()

    self.Button1 = Button(self.bas eContainer, command =
    self.buttonClic k)
    self.Button1.co nfigure(text="S ubmit")
    self.Button1.pa ck()


    def buttonClick(sel f):
    print "Button1 was clicked"
    path = self.e.get()
    path = "\"" + path + "\""
    os.startfile(pa th)

    def entryEnter(self , event):
    print "Enter was hit in the entry box"
    self.buttonClic k()


    root = Tk()
    myapp = myApp(root)
    root.mainloop()

    [code]



    Alexnb wrote:
    >
    I don't get why yall are being so rude about this. My problem is this; the
    path, as a variable conflicts with other characters in the path, creating
    escape characters I don't want, so I need a way to send the string to the
    os.startfile() in raw, or, with all the backslashes doubled. Thats it,
    I'll write some code of what it should work like, because I probably
    should have done that; but you don't have to act like I am retarded...
    that solves nothing.
    >
    >
    Grant Edwards wrote:
    >>
    >On 2008-06-11, Alexnb <alexnbryan@gma il.comwrote:
    >>
    >>Okay, so as a response to all of you, I will be using the Entry() widget
    >>in
    >>Tkinter to get this path.
    >>
    >OK.
    >>
    >>and the repr() function just makes all my backslashes 4
    >>instead of just 1, and it still screwes it up with the numbers
    >>and parenthesis is has been since the first post.
    >>
    >I've absolutely no clue why you would be using the repr()
    >function.
    >>
    >>Oh and I know all about escape characters, (\n,\b,\a,etc.)
    >>
    >Apparently not.
    >>
    >>I can program C, not a lot, but enough to know that I like
    >>python better. Anyway, so far I tried all of your stuff, and
    >>it didn't work.
    >>
    >To what does "it" refer?
    >>
    >>infact, it puts backslashes in front of the
    >>"'" in some of the words, such as "I'm" goes to "I\'m."
    >>
    >Again, "it" doesn't seem to have a concrete referant.
    >>
    >>So I posted the code I will be using if you want to see the
    >>Tkinter code I can post it, but I don't see how it will help.
    >>
    >If you know what would help and what wouldn't, then you must
    >know enough to fix your problems. So please do so and quit
    >bothering the newgroup.
    >>
    >--
    >Grant Edwards grante Yow! I want another
    > at RE-WRITE on my CEASAR
    > visi.com SALAD!!
    >--
    >http://mail.python.org/mailman/listinfo/python-list
    >>
    >>
    >
    >
    --
    View this message in context: http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p1778 6712.html
    Sent from the Python - python-list mailing list archive at Nabble.com.

  • Duncan Booth

    #2
    Re: basic code of what I am doing

    Alexnb <alexnbryan@gma il.comwrote:
    path = self.e.get()
    path = "\"" + path + "\""
    os.startfile(pa th)
    Why are you adding spurious quote marks round the filename? os.startfile()
    will strip them off, but you don't need them. The help for os.startfile()
    does say though that the path must not start with a /, so you should use
    os.normpath to be on the safe side:

    os.startfile(os .path.normpath( self.e.get())

    Anyway, the code works either with that change, or as you originally wrote
    it provided the path does not start with /. What was the question again?

    Comment

    Working...