I have an existing program that populates a Popmenu from a database query and it works in Windows but when I compile for the Pi, the control is disabled, and no data in Popmenu. Xojo. Xojo 2020 R2.1
Raspbian 10 (Buster). I have it based on the GetFocus and Change event handlers
Try populating it in the Open event instead of GotFocus. It may just be too late in that event.
I tried that Greg but got an exception, forget which one. As I mentioned, the code as is works in Windows 10 in the Getfocus event, so It’s definitely a bug
Please show us some code how you are populating this popupmenu.
DIM rs AS rowset
Me.DeleteAllRows
rs = DbModule.QueryPlantName("")
IF rs <> NIL THEN
WHILE NOT rs.AfterLastRow
me.addrow rs.ColumnAt(1).StringValue
rs.movetonextrow
WEND
ELSE
Msgbox(“No Data Found”)
END IF
There is a function in dbmodule, but I won’t include that. As I mentioned this works in Windows 10
I just compiled it with 2019 R1 with the old frameworks ie Recordset vs Rowset and the dropdown doesn’t work in Pi either. The rest of the app works in Pi ie general DB queries with listboxes etc
DIM rs AS rowset
Me.DeleteAllRows
rs = DbModule.QueryPlantName("")
IF rs <> NIL and rs.Count > 0 THEN
WHILE NOT rs.AfterLastRow
me.addrow rs.ColumnAt(1).StringValue
rs.movetonextrow
WEND
ELSE
Msgbox(“No Data Found”)
END IF
try this. Perhaps it’s not returning rows but RS is still set. it’s unclear from this code where the problem may be. It could be the db has no rows containing data from your query. it could be something else. Try to catch any errors in the DB.connect and db Select and execute using Try … Catch …
I populate mine in the Open event with no trouble at all. If that gives you an exception then use the debugger to find out why.
No go
No exception Tim, the control is even disabled
On Pi? with a db populating control?
Yes, on a Pi 4B using remote debugging with the IDE running on my Mac Mini (Mojave).
Here is my code to populate the PopupMenu (which is what I assume you mean by Popmenu):
Open handler:
Var i, absid As Integer, dbhs As SQLiteDatabase, regs As RowSet
dbhs = dbconnect ("Settings", "ASO1")
regs = dbhs.dbquery ("select absid from accounts", "ASO2")
i = 0
while (regs.AfterLastRow=false)
absid = regs.Column("absid").IntegerValue
if (absid=app.defaultAcctPtr) then
currAcct = i
Exit
end if
i = i + 1
regs.MoveToNextRow ()
wend
dbhs.Close ()
Call loadPrefsaccts (acctssel, acctsmsgarea)
The loadPrefsaccts()
method looks like this:
Var i As Integer, dbhs As SQLiteDatabase, regs As RowSet, acctname as String
dbhs = dbconnect ("Settings", "LPA1")
regs = dbhs.dbquery ("select absid, account_name from accounts", "LPA2")
if (regs=Nil) then
prefsmsg (ptrms, "Error: cannot read list of accounts", "red")
Return False
end if
i = 0
ptrpu.RemoveAllRows ()
while (regs.AfterLastRow=false)
acctname = regs.Column("account_name").stringValue
ptrpu.AddRow (acctname.ReplaceAll ("&", "&&"))
ptrpu.RowTagAt(i) = regs.Column("absid").IntegerValue
regs.MoveToNextRow ()
i = i + 1
wend
dbhs.Close ()
if (i=0) then disableAcctsFields ()
if (i>0) then
enableAcctsFields ()
ptrpu.SelectedRowIndex = currAcct
end if
Return True
So that’s all happening in the Open event handler. I have my own wrapper for the SQLite methods which look after catching errors and reporting them.
Ok Tim,let me work with it a bit. I am off to Greenhouse, lettuce season has begun. Thank you for your input and I will post back after a bit. I’m just miffed that it works in Windows and same code compiled for Pi, doesn’t I’ve never go remote debugging working from Windows, I get some obscure error. So I compile on Windows and Filezilla it over to Pi. Failed to connect properly. Malicious Termination occurred I think it was
Probably timing issues. The remote debugging is really worth it, believe me. I have a real Pi but it also works into Linux, Win7, and Win10 VMs that I run on my Mini under VirtualBox. The VMs run a bit slow, so for something like animation real hardware is preferred, but for ordinary working the VMs are good.
Sometimes things don’t work properly under Linux but mostly I’ve found workarounds so it’s worth persevering. I’d strongly recommend finding out what is the issue you have with remote debugging - if you get stuck then start a new topic about it.
I’m tenacious Tim. My real job is an Oracle Database Programmer, PL/SQL, 35 years of it. I love Xojo and the Pi. I wish there was a native app for Pi. I understand 4 gig is tight for the IDE but perhaps an 8 gig Pi would handle it. I will post updates on both. I opened port 44553 as well but that didn’t do it
I think the problrm the Pi has is that it’s quite minimalist, and the GPU is a bit underpowered for desktop usage. Cheapness comes at a cost, so to speak. F’rinstance, and this is nothing to do wth Xojo, it can’t even do live resizing of a window. I saw this in my app and then tried it on the Finder/Explorer equivalent on the Pi. If you drag a window edge to make it bigger, the new content of the window doesn’t appear until you let go of the mouse. Perhaps that doesn’t matter for most usage, if all one is doing is a bit of email and browsing, with the occasional bit of word processing.
That port is the default, Make sure that on the Pi side the Remote Debugger Desktop app is using the default network interface, and give it a name but no password. Also ensure that "Launch executable … " is ticked.
On the host side, with the project open you’ll need to go to Run remotely → Setup… on the Project menu. That should make Xojo AIUI check which remote desktop deguggers are reachable and offer your Pi in the Run remotely submenu of the Project menu. All I do then is choose the Pi and wait.
Ya, I had a RTFM moment, I should have read the docs. I installed the app and a great fella Greg walked me through it. I should have known better Tim. I really like Xojo. I’ve written quite a few programs with it. One was an HL7 generator for our Health Care System. Another is my Seed Manager. I have over 400 seed packs that I keep track of, Heirloom varieties that I want to keep going forward. And a Weather program, that uses an API, and JSON to get current conditions, right down to the moon phase and I translate that into ‘Waxing Gibbous’ or ‘Waning Gibbous’. It’s a great IDE and programing environment. You can go full Object Oriented or like an old fella like me; procedural. I use to have the Database version but being in Canada, the exchange rate sucks. So I managed Oracle access with OLEDB with Oracle Instant client with the Lite Version. I was thinking MBS Sql plugin with the Lite version but SQLite is a very capable database. I’ve been a customer since 2005 and the code just oozes outta me when I hit my stride. I will definitely buy/upgrade to the Android version when it comes out. I’m close to retired, at 57 and love tinkering around with code. As far as the Pi goes, yes, it was meant for educational use but damm it’s quiet and I’m partially off grid an sips power. A scant 2 watts and my 32" monitor consumes about 32 watts. Compared to my 300 watt desktop. Thanks again for your help
Glad you got that going. @Greg_O_Lone is a very helpful and patient guy, useful assets in this business.
Ok, Tim now that I have the debugger going. When I add a debug point on gotfocus or change, the control is not even enabled to receive mouse input. None of my populated popmenu controls are enabled. Only popmenu enabled is one I prepopulate with static text. The program works in windows fine