Simple GUI
#38
Here are some images from Simple GUI for FreeBasic to give an idea of what can be achieved.  It provides just about everything that Inform does with the exception of a form designer.

Listbox
[Image: Listbox.jpg]

Code for Listbox:
Code: (Select All)
'===============================================================================
' GUI_Test_Listbox.bas
' Jan 17, 2015
' Latest revion November 28, 2016
'===============================================================================

#Include "GUI.bi"

Dim Shared As ListBox LB
Dim Shared As TextBox Text_Add, Text_index, Text_text
Dim Shared As Button Button_Add, Button_SetItem, Button_DeleteItem, Button_InsertItem, _
                            Button_Clear

Dim Shared As Integer index

Sub OpenWindow_Main()
'Window

    Dim As Integer i
    
    OpenWindow(400, 440, "Test Listbox")
    LB = ListBox_New(20, 20, 150, 400)
    Text_Add = TextBox_New(200, 50, 150, 20, "")
    Button_Add = Button_New(200, 80, 100, 20, "Add")
    Var Label_index = Label_New(200, 160, 150, 20, "Index:")
    Text_index    = TextBox_New(200, 180, 150, 20, "")
    Var Label_text = Label_New(200, 210, 150, 20, "Text:")
    Text_text = TextBox_New(200, 230, 150, 20, "")
    Button_SetItem = Button_New(200, 260, 100, 20, "Set Text")
    Button_DeleteItem = Button_New(200, 290, 100, 20, "Delete Item")
    Button_InsertItem = Button_New(200, 320, 100, 20, "Insert Item")
    
    Button_Clear = Button_New(200, 400, 150, 20, "Clear Listbox")
    
    For i = 0 To 20
        ListBox_Add(LB, "Item number: " + Str(i))
    Next
        
End Sub


Sub LB_EventHandler()
'Event handler of Listbox

    Dim As String text
    
    index = ListBox_GetIndex(LB)
    text = ListBox_GetItem(LB, index)
    TextBox_SetText(Text_index, Str(index))
    TextBox_SetText(Text_text, text)
    
End Sub
    
    
'Main:    

OpenWindow_Main()

Do
    If ListBox_Event(LB) Then LB_EventHandler()
    If TextBox_Event(Text_Add) Then TextBox_Edit(Text_Add)
    If Button_Event(Button_Add) Then ListBox_Add(LB, TextBox_GetText(Text_Add))
    If TextBox_Event(Text_text) Then TextBox_Edit(Text_text)
    If Button_Event(Button_SetItem) Then ListBox_SetItem(LB, index, TextBox_GetText(Text_text))
    If Button_Event(Button_DeleteItem) Then ListBox_DeleteItem(LB, index)
    If Button_Event(Button_InsertItem) Then _
        ListBox_InsertItem(LB, TextBox_GetText(Text_text), index)
    If Button_Event(Button_Clear) Then ListBox_Clear(LB)
Sleep 1
Loop Until Window_Event_Close

End

So the code is easy to write without a Form Designer.  I prefer Hungarian notation (ButtonEvent) rather than Button_Event and I would prefer to see Textbox rather than Textbox_New, but these are my own personal preferences and I won't be writing the library code.

@bplus has shown an interest (no pressure) and it would be great if an equivalent library could be produced for QB64.

Textbox
[Image: Textbox.jpg]
Reply


Messages In This Thread
Simple GUI - by Coolman - 04-30-2022, 10:11 AM
RE: Simple GUI - by bplus - 04-30-2022, 05:52 PM
RE: Simple GUI - by Pwillard - 06-06-2022, 12:06 PM
RE: Simple GUI - by aurel - 06-06-2022, 12:24 PM
RE: Simple GUI - by RNBW - 06-06-2022, 03:01 PM
RE: Simple GUI - by Coolman - 06-07-2022, 11:11 AM
RE: Simple GUI - by SMcNeill - 06-08-2022, 12:35 AM
RE: Simple GUI - by bplus - 06-08-2022, 01:54 AM
RE: Simple GUI - by triggered - 06-08-2022, 03:53 AM
RE: Simple GUI - by bplus - 06-08-2022, 03:48 PM
RE: Simple GUI - by aurel - 06-08-2022, 06:32 AM
RE: Simple GUI - by mpgcan - 06-08-2022, 08:09 AM
RE: Simple GUI - by aurel - 06-08-2022, 01:02 PM
RE: Simple GUI - by aurel - 06-08-2022, 01:35 PM
RE: Simple GUI - by aurel - 06-08-2022, 02:19 PM
RE: Simple GUI - by aurel - 06-08-2022, 04:33 PM
RE: Simple GUI - by aurel - 06-08-2022, 04:58 PM
RE: Simple GUI - by bplus - 06-08-2022, 06:13 PM
RE: Simple GUI - by aurel - 06-08-2022, 08:26 PM
RE: Simple GUI - by johnno56 - 06-09-2022, 05:00 AM
RE: Simple GUI - by RNBW - 06-09-2022, 03:32 PM
RE: Simple GUI - by Pete - 06-09-2022, 10:42 PM
RE: Simple GUI - by bplus - 06-09-2022, 10:37 PM
RE: Simple GUI - by aurel - 06-10-2022, 06:32 AM
RE: Simple GUI - by Coolman - 06-10-2022, 09:15 AM
RE: Simple GUI - by RNBW - 06-10-2022, 11:13 AM
RE: Simple GUI - by RNBW - 06-10-2022, 11:24 AM
RE: Simple GUI - by RNBW - 06-10-2022, 12:33 PM
RE: Simple GUI - by Coolman - 06-10-2022, 01:14 PM
RE: Simple GUI - by RNBW - 06-10-2022, 03:02 PM
RE: Simple GUI - by Coolman - 06-10-2022, 03:28 PM
RE: Simple GUI - by RNBW - 06-10-2022, 04:58 PM
RE: Simple GUI - by bplus - 06-10-2022, 05:15 PM
RE: Simple GUI - by bplus - 06-10-2022, 05:54 PM
RE: Simple GUI - by Coolman - 06-10-2022, 06:29 PM
RE: Simple GUI - by bplus - 06-10-2022, 06:57 PM
RE: Simple GUI - by aurel - 06-10-2022, 07:31 PM
RE: Simple GUI - by RNBW - 06-11-2022, 02:13 PM
RE: Simple GUI - by Coolman - 06-11-2022, 03:24 PM
RE: Simple GUI - by RNBW - 06-11-2022, 04:48 PM
RE: Simple GUI - by Coolman - 06-11-2022, 06:28 PM
RE: Simple GUI - by RNBW - 06-11-2022, 07:36 PM
RE: Simple GUI - by Coolman - 06-11-2022, 08:30 PM



Users browsing this thread: 17 Guest(s)