示例#1
0
文件: b1.2.0.py 项目: Lyxal/BreezyUI
def export():
    print("""

#############################################################
#The following code was pre-generated by BreezyUI           #
#Don't change any of the code if you don't know what it does#
#############################################################

import sys
if sys.version_info[0] == 2:
    import Tkinter as tkinter #backwards compatability
else:
    import tkinter

root = tkinter.Tk()
root.geometry("800x600") #Set the size of the window
    """)
    for i in range(len(dragged_widgets)):
        widget = dragged_widgets[i]
        to_export = bUI.changed_dict(widget.attributes,
                                     bUI.get_attributes(widget.widget))
        print("object{0} = tkinter.{1}(root, {2})".format(
            i, widget.widget_type, to_export))

        print("object{0}.place(x={1},y={2})".format(i, widget.widget.winfo_x(),
                                                    widget.widget.winfo_y()))

        if widget.widget_type == "Entry":
            if widget.widget.get():
                print("object{0}.insert(0, {1})".format(
                    i, widget.widget.get()))

    print("#################END OF GENERATED CODE#################")
示例#2
0
def export():
    code = """

#############################################################
#     The following code was pre-generated by BreezyUI.     #
#Don't change any of the code if you don't know what it does#
#############################################################

import sys
if sys.version_info[0] == 2:
    import Tkinter as tkinter #backwards compatability
else:
    import tkinter

root = tkinter.Tk()
root.geometry("{0}x{1}") #Set the size of the window
    """.format(width_var.get(), height_var.get()) + "\n"
    for i in range(len(dragged_widgets)):
        widget = dragged_widgets[i]
        to_export = bUI.changed_dict(widget.attributes, bUI.get_attributes(widget.widget))
        code += "{0} = tkinter.{1}(root, {2})".format(widget.name, widget.widget_type, to_export) + "\n"

        code += "{0}.place(x={1},y={2})".format(widget.name, widget.widget.winfo_x(), widget.widget.winfo_y()) + "\n"

        if widget.widget_type == "Entry":
            if widget.widget.get():
                code += "{0}.insert(0, {1})".format(widget.name, widget.widget.get()) + "\n"

    code += ("\n#################END OF GENERATED CODE#################")
    root.filename = tkinter.filedialog.asksaveasfilename(initialdir = "/",title = "Select file",filetypes = (("python files","*.py"),("all files","*.*")))
    file = open(root.filename + ".py", "w")
    file.write(code)
    file.close()
    return
示例#3
0
文件: b1.6.0.py 项目: Lyxal/BreezyUI
def export(event=None):
    code = ""
    code += bUI.START_COMMENT
    code += "import sys, bUI\n"
    code += "if sys.version_info[0] == 2:\n"
    code += "    import Tkinter as tkinter\n"
    code += "else:\n"
    code += "    import tkinter\n"
    code += "root = tkinter.Tk()\n"
    code += "root.geometry('{0}x{1}')\n".format(
        main_area.canvas.winfo_width(), main_area.canvas.winfo_height())

    for index in range(len(dragged_widgets)):
        widget = dragged_widgets[index]
        changed_attrs = bUI.changed_dict(widget.attributes,
                                         bUI.get_attributes(widget.widget))

        if widget.widget_type != "Text":
            code += "{0} = tkinter.{1}(root, {2})\n".format(
                widget.name, widget.widget_type, changed_attrs)

        if widget.widget_type == "Entry":
            if widget.widget.get():
                code += "{0}.insert(0, '{1}')\n".format(
                    widget.name, widget.widget.get())

        elif widget.widget_type == "Listbox":
            if len(widget.items):
                for item in widget.items[0].split("\n"):
                    code += "{0}.insert(0, '{1}')\n".format(widget.name, item)

        elif widget.widget_type == "Text":
            code += "{0} = bUI.Textbox(root, {1}, {2}, {3})\n".format(
                widget.name, widget.width, widget.height, changed_attrs)

        code += "{0}.place(x={1}, y={2})\n".format(widget.name,
                                                   widget.widget.winfo_x(),
                                                   widget.widget.winfo_y())

    code += bUI.END_COMMENT
    code += "\n\n\n\n\n\n\nroot.mainloop() #Ensure that you keep this line, as it was added by BreezyUI"

    with open("../Resources/directory.txt") as last_directory:
        directory = last_directory.read().strip()

    root.filename = tkinter.filedialog.asksaveasfilename(
        initialdir=directory,
        title="Select file",
        filetypes=(("python files", "*.py"), ("all files", "*.*")))

    with open("../Resources/directory.txt", "w") as last_directory:
        last_directory.write(os.path.dirname(root.filename))

    import shutil
    shutil.copy("../Libraries/bUI.py", os.path.dirname(root.filename))
    file = open(root.filename + ".py", "w")
    file.write(code)
    file.close()
示例#4
0
文件: b1.4.1.py 项目: Lyxal/BreezyUI
def export():
    code = """

#############################################################
#     The following code was pre-generated by BreezyUI.     #
#Don't change any of the code if you don't know what it does#
#############################################################

import sys
if sys.version_info[0] == 2:
    import Tkinter as tkinter #backwards compatability
else:
    import tkinter

root = tkinter.Tk()
root.geometry("{0}x{1}") #Set the size of the window
    """.format(width_var.get(), height_var.get()) + "\n"
    for i in range(len(dragged_widgets)):
        widget = dragged_widgets[i]
        to_export = bUI.changed_dict(widget.attributes,
                                     bUI.get_attributes(widget.widget))
        code += "{0} = tkinter.{1}(root, {2})".format(
            widget.name, widget.widget_type, to_export) + "\n"

        code += "{0}.place(x={1},y={2})".format(widget.name,
                                                widget.widget.winfo_x(),
                                                widget.widget.winfo_y()) + "\n"

        if widget.widget_type == "Entry":
            if widget.widget.get():
                code += "{0}.insert(0, '{1}')".format(
                    widget.name, widget.widget.get()) + "\n"

    code += "\n#################END OF GENERATED CODE#################"
    code += "\n#Add your code beneath this line"
    code += "\n\n\nroot.mainloop() #No more code after this"

    last_dir_f = open("../Resources/directory.txt")
    last_dir = last_dir_f.read().strip("\n")
    last_dir_f.close()

    root.filename = tkinter.filedialog.asksaveasfilename(
        initialdir=last_dir,
        title="Select file",
        filetypes=(("python files", "*.py"), ("all files", "*.*")))

    last_dir_f = open("../Resources/directory.txt",
                      "w")  #Truncate the file on purpose.
    last_dir_f.write(os.path.dirname(root.filename))
    last_dir_f.close()

    file = open(root.filename + ".py", "w")
    file.write(code)
    file.close()
    return
示例#5
0
文件: b1.5.0.py 项目: Lyxal/BreezyUI
def save_bUI_file():

    with open("../Resources/directory.txt") as last_directory:
        directory = last_directory.read().strip()

    bui_filetypes = (("BreezyUI Files", "*.bui"), ("all files", "*.*"))

    root.filename = tkinter.filedialog.asksaveasfilename(initialdir=directory, title="Select file", filetypes=bui_filetypes)

    with open("../Resources/directory.txt", "w") as last_directory:
        last_directory.write(os.path.dirname(root.filename))

    save_file = open(root.filename + ".bui", "w")
    contents = "[{0}, {1}]".format(width_var.get(), height_var.get())


    #Generate the bUI file
    for widget in dragged_widgets:

        widget_config = {
            "id" : widget.name,
            "display" : widget.display,
            "type" : widget.widget_type,
            "x" :  widget.widget.winfo_x(),
            "y" : widget.widget.winfo_y(),
            "attributes" : bUI.changed_dict(widget.attributes, bUI.get_attributes(widget.widget))
        }

        if widget.args != {}:
            for arg in widget.args:
                widget_config["attributes"][arg] = widget.args[arg]

        if widget.widget_type == "Entry":
            widget_config["attributes"]["Placeholder"] = "'" + widget.widget.get() + "'"

        if widget.widget_type in ["Text", "Listbox"]:
            widget_config["attributes"]["width"] = 200
            widget_config["attributes"]["height"] = 100
            widget_config["attributes"]["relief"] = "solid"
            widget_config["attributes"]["bd"] = 1

        if widget.widget_type == "OptionMenu":
            widget_config["attributes"]["value"] = "'{0}'".format(widget["text"])



        contents += str(widget_config)

    save_file.write(contents);save_file.close()

    #Add the bUI file to the recents list
    file = open("../Resources/recent.txt", "a")
    file.write(root.filename + ".bui" + "\n")
    file.close()
示例#6
0
文件: b1.4.1.py 项目: Lyxal/BreezyUI
def save_bUI_file():

    last_dir_f = open("../Resources/directory.txt")
    last_dir = last_dir_f.read().strip("\n")
    last_dir_f.close()

    root.filename = tkinter.filedialog.asksaveasfilename(
        initialdir=last_dir,
        title="Select file",
        filetypes=(("python files", "*.py"), ("all files", "*.*")))

    last_dir_f = open("../Resources/directory.txt",
                      "w")  #Truncate the file on purpose.
    last_dir_f.write(os.path.dirname(root.filename))
    last_dir_f.close()
    file = open(root.filename + ".bui", "w")
    file.write("[{0}, {1}]".format(width_var.get(), height_var.get()))

    #Generate the bUI file
    for widget in dragged_widgets:
        widget_config = {
            "id":
            widget.name,
            "type":
            widget.widget_type,
            "x":
            widget.widget.winfo_x(),
            "y":
            widget.widget.winfo_y(),
            "attributes":
            bUI.changed_dict(widget.attributes,
                             bUI.get_attributes(widget.widget))
        }

        if widget.widget_type == "Entry":
            widget_config["attributes"][
                "Placeholder"] = "'" + widget.widget.get() + "'"

        file.write(str(widget_config))

    #Add the bUI file to the recents list
    file = open("../Resources/recent.txt", "a")
    file.write(root.filename + ".bui" + "\n")
    file.close()
示例#7
0
def save_bUI_file():
    root.filename = tkinter.filedialog.asksaveasfilename(
        initialdir="/",
        title="Select file",
        filetypes=(("python files", "*.py"), ("all files", "*.*")))
    file = open(root.filename + ".bui", "w")

    #Generate the bUI file
    for widget in dragged_widgets:
        widget_config = {
            "id":
            widget.name,
            "x":
            widget.widget.winfo_x(),
            "y":
            widget.widget.winfo_y(),
            "attributes":
            bUI.changed_dict(widget.attributes,
                             bUI.get_attributes(widget.widget))
        }
        #TODO: Figure out how to get placeholder of entries.
        file.write(str(widget_config))
示例#8
0
def save_bUI_file():
    root.filename = tkinter.filedialog.asksaveasfilename(initialdir = "/",title = "Select file",filetypes = (("python files","*.py"),("all files","*.*")))
    file = open(root.filename + ".bui", "w")

    #Generate the bUI file
    for widget in dragged_widgets:
        widget_config = {"id" : widget.name, "type" : widget.widget_type, "x" : widget.widget.winfo_x(), "y" : widget.widget.winfo_y(), "attributes" : bUI.changed_dict(widget.attributes, bUI.get_attributes(widget.widget))}

        if widget.widget_type == "Entry":
            widget_config["attributes"]["Placeholder"] = widget.widget.get()

        file.write(str(widget_config))

    #Add the bUI file to the recents list
    file = open("../Resources/recent.txt", "a")
    file.write(root.filename + ".bui" + "\n")
    file.close()