How to add a window in wxpython other then parent frame and use information in sqlite query - sqlite

I have a button in my parent frame(named as Add). I want to open a TextEntryDialog when user clicks that button,I want to open it like a pop up window.And i have to send that text typed by user back to parent frame, which i am going insert into my database table. It would be better if i can make a editable listctrl, in which i will have 4 columns and user will fill information into those columns and by sqlite query i will fill that information into database table.So how can i accomplish this?

First tutorial on the first page of a search for "wxpython text dialog"
https://pythonspot.com/en/wxpython-input-dialog/
You don't appear to have put in any effort whatsoever!
#!/usr/bin/python
import wx
def onButton(event):
print "Button pressed."
app = wx.App()
frame = wx.Frame(None, -1, 'win.py')
frame.SetDimensions(0,0,200,50)
# Create text input
dlg = wx.TextEntryDialog(frame, 'Enter some text','Text Entry')
dlg.SetValue("Default")
if dlg.ShowModal() == wx.ID_OK:
print('You entered: %s\n' % dlg.GetValue())
dlg.Destroy()

Related

window form goes not responding stage

I am new to progress 4GL. In my program, I tried to create a form using progress 4GL. The form has two fields one is DB name and another one is DB Description. The scope of this form is by default this should have one DB name and description and if a user-entered or keep blank in the field of DB name then an alert box should give a message. I have developed the form but when I run it the program keeps continuously running and window form goes not responding stage. I don't get a chance to enter or keep blank to the DB field name. Let me share my code and please help to find out what is the issue and why it's continuously running.
define variable cArcDB as character no-undo format "x(20)" INIT "qadb".
define variable cArcDBDesc as character no-undo format "x(25)" INIT "archive database".
define variable cTmp as character NO-UNDO.
form
cArcDB colon 25
cArcDBDesc colon 25
with frame frArchiveDB width 80 side-labels.
MAIN-LOOP:
REPEAT:
display
cArcDB
cArcDBDesc
with frame frArchiveDB.
set
cArcDB
with frame frArchiveDB editing:
if frame-field = "cArcDB" then do:
/* Find next/prev record from ttAppDB */
cTmp = cArcDB:input-value in frame frArchiveDB.
display
cArcDB
cArcDBDesc
with frame frArchiveDB.
end.
end. /* editing */
cArcDB = trim(cArcDB).
if cArcDB = "" then do:
/* Blank not allowed */
/* {us/bbi/pxmsg.i &MSGNUM=40 &ERRORLEVEL=3} */
next-prompt cArcDB with frame frArchiveDB.
undo MAIN-LOOP,retry MAIN-LOOP.
end.
END.
Please have look at the online reference of the "EDITING phrase". To me it looks like you're missing the READKEY after the beginning of the EDITING block and you also need to "APPLY LASTKEY" at some point. See the sample there:
/* Update Customer fields, monitoring each keystroke during the UPDATE */
UPDATE Customer.Name Customer.Address Customer.City Customer.State SKIP
Customer.SalesRep HELP "Use the space bar to select a SalesRep"
WITH 2 COLUMNS EDITING: /* Read a keystroke */
READKEY.
/* If the cursor is in any field except SalesRep, execute the last key
pressed and go on to the next iteration of this EDITING phrase to check
the next key */
IF FRAME-FIELD <> "SalesRep" THEN DO:
APPLY LASTKEY.
IF GO-PENDING THEN LEAVE.
ELSE NEXT.
END.
/* When in the SalesRep field, if the last key pressed was the space bar
then cycle through the sales reps */
IF LASTKEY = KEYCODE(" ") THEN DO:
FIND NEXT SalesRep NO-ERROR.
IF NOT AVAILABLE SalesRep THEN FIND FIRST SalesRep.
DISPLAY SalesRep.SalesRep # Customer.SalesRep.
NEXT.
END.
/* If the user presses any one of a set of keys while in the SalesRep field,
immediately execute that key */
IF LOOKUP(KEYFUNCTION(LASTKEY),
"TAB,BACK-TAB,GO,RETURN,END-ERROR") > 0 THEN APPLY LASTKEY.
ELSE BELL.
END.

Google Sheets: Click button to unhighlight row, highlight the next row, and update cell with date and time button was clicked

I'm trying to create a rotation scheduler. My goal is to have a table of names, phone numbers and a button.
When the button ('Assign') is pressed, it highlights a row, and updates a cell outside the table with the date & time it was clicked. When it is pressed again, it un-highlights that row and highlights the next row, and updates the date/time cell.
When it reaches the bottom, it should move back to the top. It should save where it left off between closing and opening the document and it needs to sync even when several users have it open... I don't think Excel can do that, but Google Sheets should be able to, which is why I'm leaning towards Google Sheets.
I completely understand if that's too much to expect someone to sort out on a forum, but I would very much appreciate even a point in the right direction as to figuring it out myself!!
When the button ('Assign') is pressed, it highlights a row, and
updates a cell outside the table with the date & time it was clicked.
You can add or create an image that acts as a button and associate a script to be triggered when it is clicked.
When it reaches the bottom, it should move back to the top.
One way of doing it is to keep track of the highlighted row and use modular arithmetic to wrap back to the start of the table.
It should save where it left off between closing and opening the
document
One option is to use the Properties Service to store the highlighted row.
I tried to implement a sample using these ideas (make a copy before you run): https://docs.google.com/spreadsheets/d/1bHN5cf2HaLTW3EbAxfXUusQnDL3dNFY313J8cdTGp4o/
The associated script:
var NUMBER_OF_ASSIGNEES = 5;
var LAST_ASSIGNMENT_DATETIME_CELL = 'G3';
var TABLE_OFFSET = 2;
function assignNewPerson(){
var sheet = SpreadsheetApp.getActive().getActiveSheet();
setAssignTime(sheet);
assignNext(sheet);
}
function setAssignTime(sheet) {
var d = new Date();
sheet.getRange(LAST_ASSIGNMENT_DATETIME_CELL).setValue(d.toLocaleTimeString());
}
function assignNext(sheet) {
// Use the Properties Service to store the current assignee index.
var documentProperties = PropertiesService.getDocumentProperties();
var currentAssigneeIndex = parseInt(documentProperties.getProperty('CURRENT_ASSIGNEE_INDEX'));
if (isNaN(currentAssigneeIndex)) {
currentAssigneeIndex = 0;
}
// Remove highlight from assignee cells.
sheet.getRange(TABLE_OFFSET + currentAssigneeIndex, 1, 1, 2).setBackground("white");
// Increment the assignee index. If the last row is reached, go back to the start of the table.
currentAssigneeIndex = (currentAssigneeIndex + 1) % NUMBER_OF_ASSIGNEES;
documentProperties.setProperty('CURRENT_ASSIGNEE_INDEX', currentAssigneeIndex);
// Highlight assignee cells.
sheet.getRange(TABLE_OFFSET + currentAssigneeIndex, 1, 1, 2).setBackground("yellow");
}

Google Spreadsheet: "Authorisation needed" when clicking button

I made a script that should insert two new rows in Google spreadsheets and copy paste the layout and values of two other rows.
But when I press the button I get a pop up window with "authorisation needed" and can't seem to fix it.
and this is the script that it should run:
function DuplicateSelectedRows() {
var spreadsheet = SpreadsheetApp.getActive();
//spreadsheet.getRange('B:B').activate();
// spreadsheet.setCurrentCell(spreadsheet.getRange('A1'));
//Insert rows before last training (row B and C)
spreadsheet.getActiveSheet().insertColumnsBefore(spreadsheet.getActiveRange().getColumn(), 1);
spreadsheet.getActiveRange().offset(0, 0, spreadsheet.getActiveRange().getNumRows(), 1).activate();
spreadsheet.getActiveSheet().insertColumnsBefore(spreadsheet.getActiveRange().getColumn(), 1);
spreadsheet.getActiveRange().offset(0, 0, spreadsheet.getActiveRange().getNumRows(), 1).activate();
// merge cells top
spreadsheet.getRange('B2:C2').activate()
.mergeAcross();
spreadsheet.getRange('B3:C3').activate()
.mergeAcross();
//spreadsheet.getRangeList(['B:B', 'C:C']).activate();
//spreadsheet.setCurrentCell(spreadsheet.getRange('A1'));
//spreadsheet.getRange('B4:C20').activate();
//paste values in newly created rows
spreadsheet.getRange('D4:E20').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
spreadsheet.getRange('B3:C3').activate();
spreadsheet.getRange('D3:E3').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
spreadsheet.getRange('B2:C2').activate();
spreadsheet.getRange('D2:E2').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
};
go back to the script editor and press run button (triangle-shaped button)
popup window will show up asking you to authorize the script for your spreadsheet
continue and ignore all warnings
when you finished authorizing your script go back to your spreadsheet and press your button

How to Change Appearance of Text in ChUI Editor Widget

I'm using an editor widget to display a longchar value read from a text file. OpenEdge 11.5 ChUI on Linux.
The logic is similar to the following:
def var mytext as longchar
init "Sample Text. Sample Text. Sample Text.".
form mytext view-as editor large inner-chars 30 inner-lines 15
scrollbar-horizontal scrollbar-vertical
with frame frame1 no-labels no-box.
view frame frame1.
display mytext with frame frame1.
mytext:read-only = yes.
enable mytext with frame frame1.
wait-for end-error of mytext.
When the editor is displayed, the text in the editor widget is "highlighted" (i.e., shown in reverse video). (See screenshot below.)
Is there a way to display the text in the editor widget so that it is not "highlighted"?
I usually do something like this:
/* textedit.p
*
* a file viewer
*
*/
define variable fileName as character no-undo format "x(30)".
define variable fileBody as longchar no-undo.
fileName = "textedit.p".
file-info:file-name = fileName.
if file-info:full-pathname = ? then
do:
message "no such file:" fileName.
pause.
quit.
end.
copy-lob from file file-info:full-pathname to fileBody.
display
fileBody view-as editor inner-chars 160 inner-lines 52 large no-word-wrap
with
no-box
no-labels
color display normal prompt normal /* this changes the coloring */
.
pause.
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/color-phrase.html
You can also fiddle with frame and widget attributes if you prefer that sort of thing.

How do I create an expanding field editor in a LiveCode DataGrid?

I need to create a field editor in a LiveCode DataGrid that grows as the user types to fit the formattedHeight of the field. The rest of the underlying row control needs to resize too along with shifting any subsequent row controls down.
Answering my own question as it may be useful to others.
Copy the field editor behavior button from the revDataGridLibrary stack to the card with the row template on it.
Edit the script of the field to be edited as follows (note you will need to fix the behavior button reference to be the long id of your new field edtior behaviour):
on preOpenFieldEditor pEditor
set the behavior of pEditor to the long id of button id 1023 of card id 1010 of stack "Data Grid Templates 1362091650635"
set the uRowControl of pEditor to the long id of the owner of me
end preOpenFieldEditor
Edit the field editor behavior script adding the following:
local sHeight,sRowControl
setProp uRowControl pRowControl
put pRowControl into sRowControl
end uRowControl
on openField
put the formattedHeight of me into sHeight
pass openField
end openField
on textChanged
local tHeight,tRect
lock screen
put the formattedHeight of me into tHeight
if sHeight <> tHeight then
put the rect of me into tRect
put item 2 of tRect+ tHeight into item 4 of tRect
set the rect of me to tRect
put tHeight into sHeight
dispatch "UpdateRow" to sRowControl with the long id of me
end if
unlock screen
pass textChanged
end textChanged
Now edit the row template behaviour adding the following handler (Note that in this case the field being edited is named "note" so you will want to change that for your use case):
on UpdateRow pFieldEditor
set the rect of graphic "Background" of me to the rect of pFieldEditor
set the rect of fld "note" of me to the rect of pFieldEditor
set the rect of me to the formattedRect of me
put the uScriptLocal["sTableObjectsA"] of me into tTableObjectsA
repeat for each line tControl in tTableObjectsA["all row controls"]
delete word -2 to -1 of tControl -- of me
put tControl into tControlA[the dgIndex of tControl]
end repeat
put the bottomLeft of me into tTopLeft
repeat for each item tIndex in tTableObjectsA["current"]["indexes"]
if tIndex > the dgIndex of me then
set the topLeft of tControlA[tIndex] to tTopLeft
put the bottomLeft of tControlA[tIndex] into tTopLeft
end if
end repeat
end UpdateRow
Looks useful, Monte. Question: why the preOpenField handler? Can't that info just be set once at design time? Does the DataGrid create a new field control each time the editor is invoked?

Resources