SourceForge logo
SourceForge logo
Menu

wxlua-users — wxLua list for users and developers

You can subscribe to this list here.

2005 Jan
Feb
Mar
Apr
May
Jun
(60)
Jul
(35)
Aug
(32)
Sep
(5)
Oct
(5)
Nov
(58)
Dec
(34)
2006 Jan
(114)
Feb
(184)
Mar
(153)
Apr
(90)
May
(153)
Jun
(59)
Jul
(24)
Aug
(43)
Sep
(17)
Oct
(34)
Nov
(11)
Dec
(204)
2007 Jan
(84)
Feb
(119)
Mar
(38)
Apr
(28)
May
(52)
Jun
(105)
Jul
(64)
Aug
(67)
Sep
(14)
Oct
(3)
Nov
(28)
Dec
(55)
2008 Jan
(228)
Feb
(55)
Mar
(30)
Apr
(30)
May
(15)
Jun
(20)
Jul
(12)
Aug
(3)
Sep
(13)
Oct
(54)
Nov
(35)
Dec
(35)
2009 Jan
(19)
Feb
(20)
Mar
(34)
Apr
(4)
May
(60)
Jun
(25)
Jul
(16)
Aug
(51)
Sep
(19)
Oct
(62)
Nov
(21)
Dec
(12)
2010 Jan
(1)
Feb
Mar
(4)
Apr
(12)
May
(23)
Jun
(13)
Jul
(1)
Aug
(40)
Sep
(18)
Oct
(21)
Nov
(26)
Dec
(34)
2011 Jan
(17)
Feb
(23)
Mar
(1)
Apr
(10)
May
(1)
Jun
(5)
Jul
(1)
Aug
Sep
Oct
(2)
Nov
Dec
(43)
2012 Jan
(5)
Feb
(19)
Mar
(6)
Apr
(24)
May
(39)
Jun
(83)
Jul
(29)
Aug
(36)
Sep
(64)
Oct
(55)
Nov
(12)
Dec
(7)
2013 Jan
(17)
Feb
(10)
Mar
(37)
Apr
(27)
May
(13)
Jun
(9)
Jul
(7)
Aug
(61)
Sep
(23)
Oct
(23)
Nov
(30)
Dec
(16)
2014 Jan
(23)
Feb
(13)
Mar
(9)
Apr
(17)
May
(2)
Jun
(11)
Jul
(2)
Aug
Sep
(9)
Oct
(24)
Nov
(2)
Dec
(14)
2015 Jan
(6)
Feb
(4)
Mar
(17)
Apr
May
(7)
Jun
(3)
Jul
Aug
Sep
(2)
Oct
(21)
Nov
(6)
Dec
(2)
2016 Jan
(4)
Feb
(2)
Mar
(7)
Apr
(3)
May
(11)
Jun
(6)
Jul
Aug
(1)
Sep
Oct
Nov
Dec
2017 Jan
Feb
Mar
Apr
(1)
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2018 Jan
(2)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2019 Jan
Feb
Mar
(6)
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
(1)
Oct
Nov
Dec
2022 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(2)
Nov
(4)
Dec
2023 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(8)
Nov
Dec
2024 Jan
Feb
Mar
Apr
May
Jun
Jul
(2)
Aug
Sep
Oct
Nov
Dec
S M T W T F S






1
(10)
2
(4)
3
(2)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(1)





Showing 17 results of 17

From: Andre A. <ar...@ki...> - 2011年01月31日 19:25:18
I have added a project to sourceforge named luathread.
Based on Enhanced Coroutine in Lua by Patrick Rapin.
in Lua Programming gems.
This allow thread both blocking and none-blocking to be run.
also supports running lua functions in a separate thread.
This code also works with wxlua
Andre
From: Lostgallifreyan <z....@bt...> - 2011年01月03日 00:22:38
Andre Arpin <ar...@ki...> wrote:
(03/01/2011 00:01)
>Lostgallifreyan <z.crow@...> writes:
>
>
>> 
>> I have one question: Is N in the for loop implicitly local? Or is it a 
>global that Strict failed to notice?
>> 
>
>
>for i= 1, 2 do
>end 
>print(i)
>
>output: nil
>
>strictly local
>
Thanks. I should have thought of that test. Got to stop for awhile to let things settle down, that kind of forgetting comes from trying to think of too much at once.
From: Andre A. <ar...@ki...> - 2011年01月03日 00:02:07
Lostgallifreyan <z.crow@...> writes:
> 
> I have one question: Is N in the for loop implicitly local? Or is it a 
global that Strict failed to notice?
> 
for i= 1, 2 do
end 
print(i)
output: nil
strictly local
Andre
From: Lostgallifreyan <z....@bt...> - 2011年01月02日 19:44:26
Andre Arpin <ar...@ki...> wrote:
(02/01/2011 13:24)
>I recommend that use strict while testing and only use necessary global 
>variables. You will be amazed at the number of time it will shorten your 
>coding cycle.
I set up a copy of Strict.lua (in the base Lua/wxLua directory), and re-ordered the SpinCtrl script as follows:
require("Strict") -- Test for correct initial declaration of global variables.
FRAME=wx.wxFrame(wx.NULL,-1,"")
PANEL=wx.wxPanel(FRAME,-1)
SC={}
NT={[0]="Zero","Un","Deux","Trois","Quatre","Cinq","Six","Sept","Huit","Neuf"} -- Creates a table of text representations to assist user input.
IDS=wx.wxID_HIGHEST+1 -- IDS is 'ID Start', first ID of safe range unused by system.
function Main()
 for N=1,4 do local ID=IDS+N
 SC[N]=wx.wxSpinCtrl(PANEL,ID,"",wx.wxPoint(N*62-60,2), -- Physical placement arithmetic done here to keep it simple.
 wx.wxSize(60,20),wx.wxSP_ARROW_KEYS+wx.wxTE_PROCESS_ENTER,0,9,N -- Note two 'styles' to enable arrow keys and direct text entry.
 )
 SC[N]:Connect(ID,wx.wxEVT_SCROLL_THUMBTRACK,FeedBack) -- Acts as wxEVT_COMMAND_SPINCTRL_UPDATED once did, ALWAYS signals!
 SC[N]:Connect(ID,wx.wxEVT_COMMAND_TEXT_ENTER,FeedBack) -- Required, as is wxTE_PROCESS_ENTER, to enable direct number entry.
 SC[N]:Connect(ID,wx.wxEVT_KILL_FOCUS,NoOp) -- Prevents de-focus replacing text with lowest preset number value.
 FeedBack(N)
 end
 FRAME:SetTitle("Symbolic SpinCtrl Array")
 FRAME:SetSize(258,51) FRAME:Centre() FRAME:Show()
end
function FeedBack(I)
 if type(I)=="userdata" then I=I:GetId()-IDS end -- This test allows the function to be passed an event OR an index.
 SC[I]:SetValue(NT[SC[I]:GetValue()]) -- Fetches value, indexes symbolic text to replace it for user display.
end
function NoOp() end -- Does nothing! Called to prevent unwanted inbuilt event handling.
Main()
This seems to work ok, and is the least disturbed form of my preferred way of writing. :) I tested Strict on one or two of the sample scripts. Scribble works ok with a few changes to local for crucial controls, but others were in greater need of revision. "Minimal.lua" ties a system into nasty knots, and seems to have some strange structural flaws that appear during initial attempts to correct it...
I previously thought that "main chunk" meant I could declare globals at the start of a top level (main) procedure, but it's still a function, the way I do it, so it seems I have to declare them at the outset. That's ok though, it helps me to be clear about which variables truly have to be global. I try to minimise them anyway, I don't like clutter at the top of a file...
I have one question: Is N in the for loop implicitly local? Or is it a global that Strict failed to notice?
From: Lostgallifreyan <z....@bt...> - 2011年01月02日 14:47:30
Lostgallifreyan <z....@bt...> wrote:
(02/01/2011 14:40)
>Thankyou. I'll use it. I'm usually strict in their use anyway, always creating them in Main() or using locals, but I have made exceptions it seems I shouldn't, like using _ as a temp in any case where I know its content is meaningless once its current use is done.
I think I left an unsnipped header in that last mail. Horrible mess.... :)
Anyway, I noticed that a line in Strict says this:
--"_" is special
I'm curious because I mentioned above that I use _ as a temp, before noticing this. Are there any special implications I should know about? Lua (and wxLua) have never seemed to mind that I use it this way.
From: Lostgallifreyan <z....@bt...> - 2011年01月02日 14:40:11
Andre Arpin <ar...@ki...> wrote:
(02/01/2011 13:24)
>X-Apparently-To: z....@bt... via 87.248.115.227; 2011年1月02日 13:25:29 +0000
>Received-SPF: pass (mta1014.bt.mail.ird.yahoo.com: domain of wxl...@li... designates 216.34.181.88 as permitted sender)
>X-YMailISG: kvhquv0cZAoRueHQc2qeRf0WQ9XZ1n7sym3sZMnrzKFyT2M0
> iDYqvMxPYhcPWNProLJyMq_yjHcXO00yhJ68usUlSDPOeLSd_eIqygIWpxH5
> U2oFf4nQG9_6MhZfqGp2tJ4ZcXLfLF6CqfL7khulPfnFg9CmOtt1tyq1wyge
> 187OPtvef.2lGtzRctFAWyGNsd1L5RPi5YWcxHEKMNV8Sm809sA7firGN8kd
> iRlpNMWJE4dqlBOXB5veozMy4oRxP_.12olIMsiyW148qO3vJ7621WeYWP39
> u6tkfKXrnx37aaIgg2VvXr1TScmx_7dATtNT26UKN852RVP8WxogSq4.9O7l
> N4Nz0Lp1wgmouxrVCPwSWSFcanSWLgWDXnPBScvBj55ScdhgU5qlrSLl.wAE
> iEQhK7RWR4SomTMC9A707q53ZQXRNvrbUA0CtUcI63M5IT7iX_BQjd9qbrXw
> _sBZg0Gahdhqs9qPw6JJmmI3dKw9t7YiAskrJz6F3UsVAnfGQrESzH8NCmD1
> 8gs_1LnytdAClTvtqJnR1fMWcxyqrMSrQomTx3iT8VfNeaDx
>X-Originating-IP: [216.34.181.88]
>Authentication-Results: mta1014.bt.mail.ird.yahoo.com from=kingston.net; domainkeys=neutral (no sig); from=kingston.net; dkim=neutral (no sig)
>Received: from 216.34.181.88 (EHLO lists.sourceforge.net) (216.34.181.88)
> by mta1014.bt.mail.ird.yahoo.com with SMTP; 2011年1月02日 13:25:29 +0000
>Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com)
>	by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69)
>	(envelope-from <wxl...@li...>)
>	id 1PZNw3-0003wI-Ey; 2011年1月02日 13:25:23 +0000
>Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192]
>	helo=mx.sourceforge.net)
>	by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69)
>	(envelope-from <gclwwu-wxlua-users@m.gmane.org>) id 1PZNw2-0003wC-Ky
>	for wxl...@li...; 2011年1月02日 13:25:22 +0000
>Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of m.gmane.org
>	designates 80.91.229.12 as permitted sender)
>	client-ip=80.91.229.12;
>	envelope-from=gclwwu-wxlua-users@m.gmane.org; helo=lo.gmane.org;
>Received: from lo.gmane.org ([80.91.229.12])
>	by sog-mx-2.v43.ch3.sourceforge.com with esmtp (Exim 4.72)
>	id 1PZNw1-0004Gs-6o
>	for wxl...@li...; 2011年1月02日 13:25:22 +0000
>Received: from list by lo.gmane.org with local (Exim 4.69)
>	(envelope-from <gclwwu-wxlua-users@m.gmane.org>) id 1PZNvo-000154-PM
>	for wxl...@li...; 2011年1月02日 14:25:09 +0100
>Received: from dsl-rb-64-118-22-48.wtccommunications.ca ([64.118.22.48])
>	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
>	id 1AlnuQ-0007hv-00
>	for <wxl...@li...>; 2011年1月02日 14:25:08 +0100
>Received: from arpin by dsl-rb-64-118-22-48.wtccommunications.ca with local
>	(Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00
>	for <wxl...@li...>; 2011年1月02日 14:25:08 +0100
>X-Injected-Via-Gmane: http://gmane.org/
>To: wxl...@li...
>From: Andre Arpin <ar...@ki...>
>Date: Sun, 2 Jan 2011 13:24:54 +0000 (UTC)
>Lines: 62
>Message-ID: <loo...@po...>
>References: <loo...@po...>
>	<201...@bt...>
>	<201...@bt...>
>Mime-Version: 1.0
>X-Complaints-To: us...@do...
>X-Gmane-NNTP-Posting-Host: sea.gmane.org
>User-Agent: Loom/3.14 (http://gmane.org/)
>X-Loom-IP: 64.118.22.48 (Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1;
>	WOW64; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727;
>	.NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0;
>	InfoPath.2; .NET4.0C))
>X-Spam-Score: -0.9 (/)
>X-Spam-Report: Spam Filtering performed by mx.sourceforge.net.
>	See http://spamassassin.org/tag/ for more details.
>	-1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for
>	sender-domain
>	0.6 HK_RANDOM_ENVFROM Envelope sender username looks random
>	-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
>	-0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
>	domain
>	-0.0 SPF_PASS SPF: sender matches SPF record
>X-Headers-End: 1PZNw1-0004Gs-6o
>Subject: Re: [wxlua-users] A simple general spin control
>X-BeenThere: wxl...@li...
>X-Mailman-Version: 2.1.9
>Precedence: list
>Reply-To: wxl...@li...
>List-Id: <wxlua-users.lists.sourceforge.net>
>List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/wxlua-users>, 
>	<mailto:wxl...@li...?subject=unsubscribe>
>List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=wxlua-users>
>List-Post: <mailto:wxl...@li...>
>List-Help: <mailto:wxl...@li...?subject=help>
>List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/wxlua-users>,
>	<mailto:wxl...@li...?subject=subscribe>
>Content-Type: text/plain; charset="utf-8"
>Content-Transfer-Encoding: base64
>Errors-To: wxl...@li...
>
>Lostgallifreyan <z.crow@...> writes:
>
>> 
>> I added the final call to FeedBack to correctly fill the text fields when it 
>loads, and I thought it looked
>> cool speaking German this time. :)
>> 
>> -----------------------------------------------------------------------------
>
>Cool is also one of the favorite words of my grand children. 
>I am pleased to see that you got it working and I now appreciate the 
>usefulness of the spinCntlr.
>
Kewl is also cool, if used in *strict* moderation. :) I think it applies to the SpinCtrl.
>NT={[0] = 'Null', "Eins","Zwei","Drei","Vier","Fünf", … 
>Is valid and give the same result.
>
Nice. Either I forgot it or didn't know it, but I suspected a neater way existed.
>I recommend that use strict while testing and only use necessary global 
>variables. You will be amazed at the number of time it will shorten your 
>coding cycle. Unless you are like this Australian I worked with once. He wrote 
>an editor on the development machine. I tried to enter a program ask him how 
>you make correction on the line. He said “I do not make typing errors”.
>
I used to make very few, but many more now. Aging eyesight, mostly...
>This is a slightly modified version of the original.
>
Thankyou. I'll use it. I'm usually strict in their use anyway, always creating them in Main() or using locals, but I have made exceptions it seems I shouldn't, like using _ as a temp in any case where I know its content is meaningless once its current use is done. I can always create that in Main too though. I got into the habit of creating globals there because I like to know at a glance what global variables I'm using. I also program in OPL (Psion language), and in that it's impossible to do otherwise. :) They have to be the first thing created in any procedure. I think OPL might let me make globals in the first line of a sub-procedure, but it makes no sense to me to do this, it would make it harder to keep track of them. In theory it might seem efficient to do that so no space is allocated beyond need, but there are better kinds of efficiency. I like to re-use variables a lot, so long as it makes sense to do so.
>--
>-- strict.lua
>-- checks uses of undeclared global variables
>-- All global variables must be 'declared' through a regular assignment
>-- (even assigning nil will do) in a main chunk before being used
>-- anywhere or assigned to inside a function.
>--
>
>local mt = getmetatable(_G)
>if mt == nil then
> mt = {}
> setmetatable(_G, mt)
>end
>
>mt.__declared = {}
>
>mt.__newindex = function (t, n, v)
>--"_" is special
> if n~= '_' and not mt.__declared[n] then
> local w = debug.getinfo(2, "S").what
> if w ~= "main" and w ~= "C" then
> error("assign to undeclared variable '"..n.."'", 2)
> end
> mt.__declared[n] = true
> end
> rawset(t, n, v)
>end
> 
>mt.__index = function (t, n)
> if not mt.__declared[n] and debug.getinfo(2, "S").what ~= "C" then
> error("variable '"..n.."' is not declared", 2)
> end
> return rawget(t, n)
>end
>
>Good luck
>
>Andre
>
>
>------------------------------------------------------------------------------
>Learn how Oracle Real Application Clusters (RAC) One Node allows customers
>to consolidate database storage, standardize their database environment, and, 
>should the need arise, upgrade to a full multi-node Oracle RAC database 
>without downtime or disruption
>http://p.sf.net/sfu/oracle-sfdevnl
>_______________________________________________
>wxlua-users mailing list
>wxl...@li...
>https://lists.sourceforge.net/lists/listinfo/wxlua-users
From: Andre A. <ar...@ki...> - 2011年01月02日 13:25:22
Lostgallifreyan <z.crow@...> writes:
> 
> I added the final call to FeedBack to correctly fill the text fields when it 
loads, and I thought it looked
> cool speaking German this time. :)
> 
> -----------------------------------------------------------------------------
Cool is also one of the favorite words of my grand children. 
I am pleased to see that you got it working and I now appreciate the 
usefulness of the spinCntlr.
NT={[0] = 'Null', "Eins","Zwei","Drei","Vier","Fünf", ... 
Is valid and give the same result.
I recommend that use strict while testing and only use necessary global 
variables. You will be amazed at the number of time it will shorten your 
coding cycle. Unless you are like this Australian I worked with once. He wrote 
an editor on the development machine. I tried to enter a program ask him how 
you make correction on the line. He said "I do not make typing errors".
This is a slightly modified version of the original.
--
-- strict.lua
-- checks uses of undeclared global variables
-- All global variables must be 'declared' through a regular assignment
-- (even assigning nil will do) in a main chunk before being used
-- anywhere or assigned to inside a function.
--
local mt = getmetatable(_G)
if mt == nil then
 mt = {}
 setmetatable(_G, mt)
end
mt.__declared = {}
mt.__newindex = function (t, n, v)
--"_" is special
 if n~= '_' and not mt.__declared[n] then
 local w = debug.getinfo(2, "S").what
 if w ~= "main" and w ~= "C" then
 error("assign to undeclared variable '"..n.."'", 2)
 end
 mt.__declared[n] = true
 end
 rawset(t, n, v)
end
 
mt.__index = function (t, n)
 if not mt.__declared[n] and debug.getinfo(2, "S").what ~= "C" then
 error("variable '"..n.."' is not declared", 2)
 end
 return rawget(t, n)
end
Good luck
Andre
From: Lostgallifreyan <z....@bt...> - 2011年01月01日 19:42:57
Here it is again, to save borrowing around in other threads...
function Main()
 FRAME=wx.wxFrame(wx.NULL,-1,"")
 FRAME:SetTitle("Symbolic SpinCtrl Array")
 PANEL=wx.wxPanel(FRAME,-1)
 IDS=wx.wxID_HIGHEST+1 -- IDS is 'ID Start', first ID of safe range unused by system.
 NT={"Eins","Zwei","Drei","Vier","Fünf", -- Creates a table of text representations to assist user input.
 "Sechs","Sieben","Acht","Neun"
 } NT[0]="Null"
 SC={}
 for N=1,4 do local ID=IDS+N
 SC[N]=wx.wxSpinCtrl(PANEL,ID,"",wx.wxPoint(N*62-60,2), -- Physical placement arithmetic done here to keep it simple.
 wx.wxSize(60,20),wx.wxSP_ARROW_KEYS+wx.wxTE_PROCESS_ENTER,0,9,N -- Note two 'styles' to enable arrow keys and direct text entry.
 )
 SC[N]:Connect(ID,wx.wxEVT_SCROLL_THUMBTRACK,FeedBack) -- Acts as wxEVT_COMMAND_SPINCTRL_UPDATED once did, ALWAYS signals!
 SC[N]:Connect(ID,wx.wxEVT_COMMAND_TEXT_ENTER,FeedBack) -- Required, as is wxTE_PROCESS_ENTER, to enable direct number entry.
 SC[N]:Connect(ID,wx.wxEVT_KILL_FOCUS,NoOp) -- Prevents de-focus replacing text with lowest preset number value.
 FeedBack(N)
 end
 FRAME:SetSize(258,51) FRAME:Centre() FRAME:Show()
end
function FeedBack(I)
 if type(I)=="userdata" then I=I:GetId()-IDS end -- This test allows the function to be passed an event OR an index.
 SC[I]:SetValue(NT[SC[I]:GetValue()]) -- Fetches value, indexes symbolic text to replace it for user display.
end
function NoOp() end -- Does nothing! Called to prevent unwanted inbuilt event handling.
Main()
I added the final call to FeedBack to correctly fill the text fields when it loads, and I thought it looked cool speaking German this time. :)
From: Lostgallifreyan <z....@bt...> - 2011年01月01日 19:20:45
I don't understand this. Why re-invent a good wheel? All I am concerned with is using it, and trying to resist further breakage by coders who seem not to realise how useful its current behaviour is.
Take a look at the small example I made, with four SpinCtrl's. There are several inbuilt native behaviours that I like there.
1. Click inside a SpinCtrl, then crank the mousewheel a bit.
2. Click inside a SpinCtrl, then use arrow keys, including held arrow keys.
3. Double-click in a SpinCtrl, type a single digit, hit Enter...
4. (Important). Click, scroll, or up-arrow to top of range, notice that unlike with SPIN_CTRL_UPDATED (which used to work this way too, once), the symbolic text remains shown when the range limit is hit, even though no update signal is sent for us to respond to now.
5. Use Ctrl+Enter to 'tab' to the next SpinCtrl, Enter a single digit, which correctly causes symbolic text update even though the text is still there during entry. Actually this is weird, it only works if the FIRST characters form a valid integer, which works because the cursor defaults to string start.
There could be more details I missed, but what matters is that there are lots of small and helpful details in SpinCtrl that make it excellent for fast data entry tasks, as well as numerically indexing editable tables of complex data types. For real-world interfacing between collections of items, and the numeric world in a computer, the SpinCtrl AS IT IS, barring further breakages, is second to none. Writing it from scratch is a big ask. I dare say it is worth the effort, but all I want is to see the original working, and not broken any further. It's dangerously close to becoming useless unless these points are recognised and understood by everyone in control of coding it.
Andre Arpin <ar...@ki...> wrote:
(01/01/2011 18:25)
>
>Replacing the wxTexCtrl by any kind of window should work.
>
>local baseID = wx.wxID_HIGHEST + 1
>frame = wx.wxFrame(wx.NULL,wx.wxID_ANY, 'Test spin control')
>
>local function GetChild(event, index, controlType)
> local wlist = event:GetEventObject():DynamicCast("wxWindow"):GetParent
>():GetChildren() 
> return wlist:Item(index):GetData():DynamicCast(controlType)
>end
>
>local function spinEvt(event)
> local spinButton = event:GetEventObject():DynamicCast("wxSpinButton")
> local textControl = GetChild(event, 0, "wxTextCtrl")
> textControl.Value = tostring(spinButton.Value)
>end
>
>local function textEvt(event)
> local textCtrl = event:GetEventObject():DynamicCast("wxTextCtrl")
> local spinButton = GetChild(event, 1, "wxSpinButton")
> local number = tonumber(textCtrl.Value)
> if number then spinButton.Value = number end
>end
>
>function GetSpin(id, position)
> local spinner = wx.wxControl(frame, id, position, wx.wxSize(100,50))
> local tc = wx.wxTextCtrl(spinner, id, 'text', wx.wxPoint(0,0),wx.wxSize
>(50,50))
> local sc = wx.wxSpinButton(spinner, id, wx.wxPoint(50,0), wx.wxSize(50,50))
> sc:Connect(wx.wxEVT_SCROLL_LINEDOWN, spinEvt) 
> sc:Connect(wx.wxEVT_SCROLL_LINEUP, spinEvt) 
> tc:Connect(wx.wxEVT_KEY_UP, textEvt)
> return spinner
>end
>
>local sp = GetSpin(baseID, wx.wxPoint(0,0) )
>sp = GetSpin(baseID + 1, wx.wxPoint(0,75))
>
>frame:Show(true)
>
>Andre
>
>
>------------------------------------------------------------------------------
>Learn how Oracle Real Application Clusters (RAC) One Node allows customers
>to consolidate database storage, standardize their database environment, and, 
>should the need arise, upgrade to a full multi-node Oracle RAC database 
>without downtime or disruption
>http://p.sf.net/sfu/oracle-sfdevnl
>_______________________________________________
>wxlua-users mailing list
>wxl...@li...
>https://lists.sourceforge.net/lists/listinfo/wxlua-users
From: Andre A. <ar...@ki...> - 2011年01月01日 18:25:53
Replacing the wxTexCtrl by any kind of window should work.
local baseID = wx.wxID_HIGHEST + 1
frame = wx.wxFrame(wx.NULL,wx.wxID_ANY, 'Test spin control')
local function GetChild(event, index, controlType)
 local wlist = event:GetEventObject():DynamicCast("wxWindow"):GetParent
():GetChildren() 
 return wlist:Item(index):GetData():DynamicCast(controlType)
end
local function spinEvt(event)
 local spinButton = event:GetEventObject():DynamicCast("wxSpinButton")
 local textControl = GetChild(event, 0, "wxTextCtrl")
 textControl.Value = tostring(spinButton.Value)
end
local function textEvt(event)
 local textCtrl = event:GetEventObject():DynamicCast("wxTextCtrl")
 local spinButton = GetChild(event, 1, "wxSpinButton")
 local number = tonumber(textCtrl.Value)
 if number then spinButton.Value = number end
end
function GetSpin(id, position)
 local spinner = wx.wxControl(frame, id, position, wx.wxSize(100,50))
 local tc = wx.wxTextCtrl(spinner, id, 'text', wx.wxPoint(0,0),wx.wxSize
(50,50))
 local sc = wx.wxSpinButton(spinner, id, wx.wxPoint(50,0), wx.wxSize(50,50))
 sc:Connect(wx.wxEVT_SCROLL_LINEDOWN, spinEvt) 
 sc:Connect(wx.wxEVT_SCROLL_LINEUP, spinEvt) 
 tc:Connect(wx.wxEVT_KEY_UP, textEvt)
 return spinner
end
local sp = GetSpin(baseID, wx.wxPoint(0,0) )
sp = GetSpin(baseID + 1, wx.wxPoint(0,75))
frame:Show(true)
Andre
From: Lostgallifreyan <z....@bt...> - 2011年01月01日 16:38:31
Andre Arpin <ar...@ki...> wrote:
(01/01/2011 13:51)
>also interesting is that the definition for GetValue is that it return an int 
>but in reality it returns a string.
>
As I say in the previous mail, it should allow both, explicitly! This is the best use of the intended combination control, no? GetValue, and GetText. Then we know exactly what we're after.
>I think spin control is very poorly defined. It should only accept numbers. 
>This string think is probably because someone uses spinbutton with a text 
>control and was too lazy to add the proper check. So compatibility does not 
>exist and all the programmers have to add check in there code to use it 
>properly.
>
If you mean that it should not be allowed to be sent text to display, then I disagree! You already tried to show me how to emulate, and it didn't really come close, and it can't unless you write a LOT of code, really a very large amount of code to solve what should already work as it is. The entire point of wxWidgets is undermined if this extra coding becomes necessary to do what can already be done without it!
If the internal check for numeric entry finds a string that can convert to an integer, then it can update the value whether it sees a SetText or a SetValue. Alternatively it can take a string in SetValue and convert anyway, or do nothing (as opposed to panic) if if cannot convert.
I mailed a small working demonstration of symbolic display in a SpinCtrl last night. If that isn't convincing enough, then this is a lost cause! Whatever gets fixed, it shouldn't damage this useful power that SpinCtrl has in its current form (albeit with a totally evasive event description).
>Poor definition and lousy implementation is the cause of most the porting 
>problems.
Likely true, but failure to grasp the real power in a control, thus allowing it to be eroded and demeaned, is a bigger problem. Lack of vision! That's the real risk here.
From: Lostgallifreyan <z....@bt...> - 2011年01月01日 16:26:19
Andre Arpin <ar...@ki...> wrote:
(01/01/2011 13:34)
>> The dot variant causes SpinCtrl to panic because it is trying to directly 
>address the internal value, not
>> the text field. TextCtrl is purely a text field, which is why the difference 
>wasn't revealed.
>> 
>> -----------------------------------------------------------------------------
>Odd but it might be explained. Look at the definition of wxSpinCtrl in 
>Reference Manual. There are two versions for set.
>
>void SetValue(const wxString& text)
>void SetValue(int iValue)
>
>If you look in wxWidgets there is only one definition namely the string 
>version. I don't know why the numeric version was added in wxlua probably so 
>you do not have to do SetValue(tostring(value)) for a number. This was 
>probably a mistake.
>
Very likely. I don't care, so long as it's not 'fixed' by someone who has no understanding of the power and versatility of symbolic text display in a SpinCtrl! Judging by the last 'fix' we're in grave danger of losing one of the best controls wxWidgets offers.
Actually it's entirely possible that the two documented versions are entirely intended for the same reasons I want them. The integer is obviously intended for the internal value, and the text is obviously intended for display. The latter is truly beyond dispute, though I guess normally an integer is also text, internally converted to a number. The dot method evidently bypasses this internal convertor. Ideally, I'd like to see the Get method able to do either. Better yet, have GetValue fetch the raw number, and have GetText work as it sounds like it should, instead of causing an error as it does now. :) The point of a SpinCtrl was to combine a SpinButton and a SpinCtrl, yet now I find I'm fighting to prevent the versatility of that combination from being undermined. Some coder out there needs to step back from the code and look at the bigger picture.
From: Andre A. <ar...@ki...> - 2011年01月01日 13:51:55
Andre Arpin <arpin@...> writes:
> Odd but it might be explained. Look at the definition of wxSpinCtrl in 
> Reference Manual. There are two versions for set.
> 
> void SetValue(const wxString& text)
> void SetValue(int iValue)
> 
> If you look in wxWidgets there is only one definition namely the string 
> version. I don't know why the numeric version was added in wxlua probably so 
> you do not have to do SetValue(tostring(value)) for a number. This was 
> probably a mistake.
also interesting is that the definition for GetValue is that it return an int 
but in reality it returns a string.
I think spin control is very poorly defined. It should only accept numbers. 
This string think is probably because someone uses spinbutton with a text 
control and was too lazy to add the proper check. So compatibility does not 
exist and all the programmers have to add check in there code to use it 
properly.
Poor definition and lousy implementation is the cause of most the porting 
problems.
From: Andre A. <ar...@ki...> - 2011年01月01日 13:35:13
Lostgallifreyan <z.crow@...> writes:
> But now try this. :)
> 
> frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, '')
> sc = wx.wxSpinCtrl(frame,1,"",wx.wxPoint(2,2),wx.wxSize
(60,20),wx.wxSP_ARROW_KEYS+wx.wxTE_PROCESS_ENTER,0,10,5)
> frame:Show(true)
> sc.Value = 5
> sc.Value = sc.Value .. " XYZ"
> --sc:SetValue(sc.Value .. " XYZ")
> 
> Finally, retry by moving the -- to enable the :Get variant and comment out 
the dot variant on line 5.
> The dot variant causes SpinCtrl to panic because it is trying to directly 
address the internal value, not
> the text field. TextCtrl is purely a text field, which is why the difference 
wasn't revealed.
> 
> -----------------------------------------------------------------------------
Odd but it might be explained. Look at the definition of wxSpinCtrl in 
Reference Manual. There are two versions for set.
void SetValue(const wxString& text)
void SetValue(int iValue)
If you look in wxWidgets there is only one definition namely the string 
version. I don't know why the numeric version was added in wxlua probably so 
you do not have to do SetValue(tostring(value)) for a number. This was 
probably a mistake.
Andre 
From: Lostgallifreyan <z....@bt...> - 2011年01月01日 01:45:52
Lostgallifreyan <z....@bt...> wrote:
(01/01/2011 01:39)
>frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, '')
>sc = wx.wxSpinCtrl(frame,1,"",wx.wxPoint(2,2),wx.wxSize(60,20),wx.wxSP_ARROW_KEYS+wx.wxTE_PROCESS_ENTER,0,10,5)
>frame:Show(true)
>sc.Value = 5
>sc.Value = sc.Value .. " XYZ"
>--sc:SetValue(sc.Value .. " XYZ")
>
>Finally, retry by moving the -- to enable the :Get variant and comment out the dot variant on line 5.
>The dot variant causes SpinCtrl to panic because it is trying to directly address the internal value, not the text field. TextCtrl is purely a text field, which is why the difference wasn't revealed.
Sorry, Meant :Set variant, not :Get... Small error but I want to be exact when posting something this specific. Reading the value works either way with SpinCtrl, but writing into it doesn't.
From: Lostgallifreyan <z....@bt...> - 2011年01月01日 01:39:58
Andre Arpin <ar...@ki...> wrote:
(01/01/2011 00:43)
>> Which is nice but I'd hoped it cut both ways. :) Sadly, while EV.Id neatly 
>replaces EV:GetId(), you can't do
>> SC.Value=SC.Value.."text" to force text replacement in a SpinCtrl derived 
>directly from its own value,
>> but you CAN do it with SC:SetValue(SC.Value.."text"). I guess I can either 
>use the dot for reading but not
>> writing, or stay with Set and Get for symmetry... Both approaches seem 
>useful to me.
>> 
>
>
>
>I think they should be identical.
>try
>
>frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, '')
>tc = wx.wxTextCtrl(frame,1) 
>frame:Show(true)
>tc.Value = 'a'
>tc.Value = tc.Value .. ' 123'
>
But now try this. :)
frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, '')
sc = wx.wxSpinCtrl(frame,1,"",wx.wxPoint(2,2),wx.wxSize(60,20),wx.wxSP_ARROW_KEYS+wx.wxTE_PROCESS_ENTER,0,10,5)
frame:Show(true)
sc.Value = 5
sc.Value = sc.Value .. " XYZ"
--sc:SetValue(sc.Value .. " XYZ")
Finally, retry by moving the -- to enable the :Get variant and comment out the dot variant on line 5.
The dot variant causes SpinCtrl to panic because it is trying to directly address the internal value, not the text field. TextCtrl is purely a text field, which is why the difference wasn't revealed.
From: Andre A. <ar...@ki...> - 2011年01月01日 00:43:59
> 
> Which is nice but I'd hoped it cut both ways. :) Sadly, while EV.Id neatly 
replaces EV:GetId(), you can't do
> SC.Value=SC.Value.."text" to force text replacement in a SpinCtrl derived 
directly from its own value,
> but you CAN do it with SC:SetValue(SC.Value.."text"). I guess I can either 
use the dot for reading but not
> writing, or stay with Set and Get for symmetry... Both approaches seem 
useful to me.
> 
I think they should be identical.
try
frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, '')
tc = wx.wxTextCtrl(frame,1) 
frame:Show(true)
tc.Value = 'a'
tc.Value = tc.Value .. ' 123'
Andre

Showing 17 results of 17

Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /