Skip to content

Commit

Permalink
New FileEntry widget (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisteach committed Apr 22, 2017
1 parent e9bfe19 commit 3966f29
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
38 changes: 37 additions & 1 deletion appJar/appjar.py
Expand Up @@ -2660,7 +2660,7 @@ def SET_WIDGET_BG(widget, bg, external=False):
# widget with label, in frame
elif widgType == "LabelBox":
widget.config(bg=bg)
widget.theLabel.config(bg=bg)
if widget.theLabel is not None: widget.theLabel.config(bg=bg)
gui.SET_WIDGET_BG(widget.theWidget, bg)

# group of buttons or labels
Expand Down Expand Up @@ -5846,6 +5846,42 @@ def addEntry(
ent = self.__buildEntry(title, self.__getContainer(), secret)
self.__positionWidget(ent, row, column, colspan, rowspan)

def addFileEntry(
self,
title,
row=None,
column=0,
colspan=0,
rowspan=0):
ent = self.__buildFileEntry(title, self.__getContainer())
self.__positionWidget(ent, row, column, colspan, rowspan)

def __getFileName(self, title):
fileName = self.openBox()
if fileName is not None:
self.setEntry(title, fileName)

def __buildFileEntry(self, title, frame):
vFrame = LabelBox(frame)
vFrame.config(background=self.__getContainerBg())

ent = self.__buildEntry(title, vFrame)
self.setEntryDefault(title, "-- enter a filename --")
ent.pack(expand=True, fill=X, side=LEFT)

but = Button(vFrame)
# FILE = u"\U0001F4C1"
but.config(text="File", font=self.buttonFont)
command = self.MAKE_FUNC(self.__getFileName, title)
but.config(command=command)
but.pack(side=RIGHT, fill=X)
but.inContainer = True
ent.but = but

vFrame.theWidget = ent

return vFrame

def addValidationEntry(
self,
title,
Expand Down
2 changes: 2 additions & 0 deletions docs/mkdocs/docs/pythonWidgets.md
Expand Up @@ -104,6 +104,7 @@ There are four special-case entries:
* SecretEntry - this will show stars, instead of the letters typed - useful for capturing passwords.
* AutoEntry - this takes a list of words to provide auto-completion.
* ValidationEntry - can be set to valid/invalid/waiting - will colour the border green/red/black and show a ✔/✖/★
* FileEntry - provides a button to select a file

![Entries](img/1_entries.gif)

Expand All @@ -129,6 +130,7 @@ app.go()
* `.addSecretEntry(title)`
* `.addAutoEntry(title, words)`
* `.addValidationEntry(title)`
* `.addFileEntry(title)`

Each of these will add the specified type of Entry, using the title provided.

Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs/docs/whatsNew.md
Expand Up @@ -4,6 +4,7 @@
## Next version (0.07)

* Issues Resolved:
* [#137](https://github.com/jarvisteach/appJar/issues/137) - [File Entries](/pythonWidgets/#entry)
* [#136](https://github.com/jarvisteach/appJar/issues/136) - Simple [GoogleMaps](/pythonDevWidgets/#googlemaps) downloader
* [#133](https://github.com/jarvisteach/appJar/issues/133) - Improvements to [Tooltips](/pythonDialogs/#tooltips)
* [#124](https://github.com/jarvisteach/appJar/issues/124) - Switched to Python's [logging](/pythonLogging.md) feature
Expand Down
7 changes: 7 additions & 0 deletions examples/fileEnt.py
@@ -0,0 +1,7 @@
import sys
sys.path.append("../")
from appJar import gui

app=gui()
app.addFileEntry("e1")
app.go()
1 change: 1 addition & 0 deletions tests/widget_test.py
Expand Up @@ -103,6 +103,7 @@ def test_entries():
app.addEntry("e1")
app.addNumericEntry("ne1")
app.addSecretEntry("se1")
app.addFileEntry("fe1")
app.addAutoEntry("ae1", ["a", "b", "c"])
app.setAutoEntryNumRows("ae1", 5)

Expand Down

0 comments on commit 3966f29

Please sign in to comment.