0

Im using VB script to process some files for later OCR using Excel and MODI. What I want to achieve is build simple Python GUI for this program wich will be able to show range of Excel cells as output in the program GUI. I will apreaciate some sample code or library for this purpose.

euranoo
  • 69
  • 1
  • 11
  • python GUIs can be built using the `tkinter` module – WhatsThePoint Feb 21 '17 at 08:29
  • Likely the stronger Python GUI libraries at the moment are [PyQt](https://riverbankcomputing.com/software/pyqt/intro) and [wxPython](https://wxpython.org/) (specially the first). If you look for "spreadsheet" together with any of those libs you'll find several [examples](https://dzone.com/articles/excel-spreadsheet-reproduction). In any case you need to start by specifying exactly what are your GUI needs. Do you just need to view a table or actually manipulate it, like in Excel? – armatita Feb 21 '17 at 09:55
  • Just view a table (small range of cells) in GUI – euranoo Feb 21 '17 at 12:22

1 Answers1

0

ttk.treeview has cell capabilities,

from Tkinter import *
import ttk

root = Tk()

tree = ttk.Treeview(root)

tree["columns"]=("one","two")
tree.column("one", width=100 )
tree.column("two", width=100)
tree.heading("one", text="coulmn A")
tree.heading("two", text="column B")

tree.insert("" , 0,    text="Line 1", values=("1A","1b"))

id2 = tree.insert("", 1, "dir2", text="Dir 2")
tree.insert(id2, "end", "dir 2", text="sub dir 2", values=("2A","2B"))

##alternatively:
tree.insert("", 3, "dir3", text="Dir 3")
tree.insert("dir3", 3, text=" sub dir 3",values=("3A"," 3B"))

tree.pack()
root.mainloop()

But I have found that just by adding ListBoxes next to each other for each column is the quick way of spitting out csv data

omgimdrunk
  • 448
  • 4
  • 16
  • Thanks, few questions: Where is the file reference in this code? The file can be in xlsx format? – euranoo Feb 21 '17 at 09:45
  • xlsx is actually a proprietary binary file. parsing it is no small feat. Your best bet is to use CSV – omgimdrunk Feb 21 '17 at 11:39
  • 1
    .xlsx is not particularly proprietary (yes, Microsoft was heavily involved in its design, but the specs are actually open, published, and "owned" by the ECMA standards organization) and it's not so much "binary" as it is "zipped". See [this question](http://stackoverflow.com/questions/4886027/looking-for-a-clear-description-of-excels-xlsx-xml-format). Depending on what kind of data is in the sheets, parsing it might not even be that hard. But it doesn't matter, because there is [xlrd](https://pypi.python.org/pypi/xlrd), which makes it easy. – John Y Feb 21 '17 at 18:44
  • John's answer is the best answer, and informative! But I do remember the xlsx binary format from this msdn artificial: https://msdn.microsoft.com/en-us/library/office/gg615597(v=office.14).aspx They have moved the macro function from excel to it's own format under xlsm so I am curious what the new changes to the cell formatted file structure is now that it is just text. – omgimdrunk Feb 22 '17 at 03:04