[cross posted again to Mahalo answers]
My Perl/Tk script has an initial spreadsheet like grid displayed using the Tk::TableMatrix::Spreadsheet modules. My spreadsheet is programatically called $ss. This initial grid is wiped before the display of the first spreadsheet, with
$ss->pack('forget');
The script as it is now also adds $mw-> pack('forget');, but that's not necessary.
My question is how to open a second file from the File -> Open dialog box and it wipe out the first file displayed, just like the first file wipes out the initial grid? Right now the second file shows up as a complete new frame underneath the still displayed first spreadsheet.
Thanks for the help in advance.
"pack('forget')" merely removes a widget from view. It doesn't delete it, nor does it do anything with the data displayed within it. If you fail to destroy the widget you will have, in effect, a big memory leak as you create more and more spreadsheet widgets.
The quickest solution to your problem is to destroy the old widget (using the destroy method) and recreate it with the new data. Another solution is to keep the widget but use deleteRows() to remove all the existing data before inserting the data for the new file.
Related
I've got a script that finds all matching bits of text and puts them in a content control. I noticed there was a functionality to remove the content control if the text was edited ContentControl.removeWhenEdited = true. Is there a way to run this same trigger/event of when the text content changes, but instead of removing the content control trigger some custom code instead?
I figured since there's already functionality to trigger on the exact event I need, it surely can't be too complicated. I tried ContentControl.onDataChanged = MyFunction() but this only ran the function when the content control was added and couldn't rerun it when the data was infact changed.
Any and all help greatly appreciated!
When an HTML editor is used and images are added from the local computer, they are uploaded to a server and a link is obtained to put it in the image src attribute. What happens when the img element is removed from the editor? How would the image be deleted from the server? In this case I understand that the image deletion event could be detected and then call a service to delete it. But what happens if the user adds a new image and leaves the page? How would it be deleted in these cases?
In both cases, if the deletion of the images is not managed, it could happen that the server is filled with unused images. How do you usually solve this problem? How is the proper way to solve this?
That's a nice question there. And yeah, for sure the server would fill up with unused images in some point. I'm not an expert on this but I'll try to suggest something so I can implement it too in my WYSIWYG editor haha. I suppose you have a custom modal for the insertion of the image. Upon clicking the button you could save the image link to an array and at SAVE || on leaving the document edit || on popstate event you could make a regex that checks the innerHTML of the editor for the specific SRC. If is not found then you could push an ajax request with the image name so you can deleteit. For sure there are more efficient and complex ways to achieve that. Such as creating text ranges and track elements on keydown - Backspace(8) / Deletekey(46).
An other way is that you could track the images that are in use. When the document is saved regex out the images in the document, push them to a db table and periodically make a check from the back end so you can delete those that are not in use.
I don't know if my suggestions are helpful or not. I just saw an interesting subject so I jumped in. Cheers mate.
please bear with me while I try to explain my problem. I am opening a form in Add mode; the form is bound to a single table but contains a subform linked to another table - the 2 tables have a 1 to many relationship. I enter some data which triggers the autoref to populate on the main form, and create a linked record on the subform. I then click a button on the main form to open another form. Using vba on the OnClick event of this button, I save the record on the current form and create a new record in a different table. This table is the data source for the 2nd form, and I open the form filtered to the newly created record. I enter some data in this secondary form and then click a button which takes a calculated value and populates a field on the main form and then closes the second form. The problem is that when it returns to the main form it seems to have lost the original record, as if it's back in Add mode. However, if I enter data on the main form and then simply close it, I can re-open it (in Edit mode) and open the 2nd form and back again without any problem. Sorry for the long-winded explanation but hope someone can help.
I've been programming Access for almost 20 years, and I've never found a use for Add mode. In other words, it has always been more trouble than it is worth.
Since you are coding already, I would just use DoCmd.GoToRecord , , acNewRec where needed to take you to a new record. Just make sure AllowAdditions is set to Yes in form properties.
Since this question is very general, it is hard to get any more specific than this. But if you do run into a specific problem that you can demonstrate in your code, update your question and I'll take a look.
I would like to display some information to the user via Matlab App Designer's GUI. I am new to this program and can't seem to find a widget that provides what I feel should be a simple function. Am I missing something? Examples would include showing the user:
The path of the file that he/she selected
Errors such as "No files detected" that are printed in a Matlab script called on by the GUI code.
Other print statements in code such as "Done!", etc that will inform the user when a process is complete.
Is there a way to capture the output in the Matlab command line and report these in a window of some sort in the GUI? Thanks in advance!
You can use a TextArea to display information for the user. Here's how I made a simple example:
Drag a button to the app in design view.
Drag in a text area also. I changed the label to Feedback.
Select the button and use the Callbacks tab in the bottom right of app designer to add a callback with the default name it gives you.
Edit the callback to contain
answer = 'what your want to display';
app.FeedbackTextArea.Value = answer;
When you push the button the text area gets filled. In your code, instead of just setting 'answer' to some string, set a variable using whatever code is dealing with your user's information. The key is to store what you want the user to see in a variable and then assign that to the "Value" parameter of the text area or other widget where you want them to see the results.
Update: Manually losing the form and re-opening it also causes editing to be allowed, please see Step 4 below and "Additional Notes" section below. Thanks!
An MS-Access 2007 database that I have simplified a great deal during troubleshooting still has the same problem:
Restart Access and open the database
The autoexec calls a vba function that initializes some TempVars, then opens a form with: `DoCmd.OpenForm FormName:="MainEditor"
All Bound and Un-Bound Text Boxes and Combo Boxes display their data
correctly, but NONE of them can be edited. Keystrokes are ignored, pull-downs on Combo Boxes display lists of choices correctly but no choice can be selected.
Change the form's view to Design View, then immediately change it back to Form View. Alternatively, manually close the Form and then re-open it.
All the controls continue to display their data correctly, but now ALL of
them can be edited normally.
After changing to Design View and back to Form View, the Form is editable normally until Access is shut down and restarted.
Additional Notes:
I tried adding a DoCmd.Close and a DoCmd.FormOpen immediately after the original DoCmd.FormOpen in the startup function called by the Autoexec macro, but the Form remained unable to accept edits. Manually closing the form, and then manually re-opening it, seems to work every time. Is there any chance that Access needs a delay to process before opening the form, and manually doing the close/open cycle provides that time window?
Here's some background:
The Table has a primary index, 4 other indexes, and one-to-many relations to 7 other tables.
The Form's Record Source is the Table, and Allow Edits = Yes.
All the controls on the Form are set: Enabled = Yes, and Locked = No.
There are no sub-forms, only the one Form.
This isn't much to go on. If you ask for further specifics I'd be glad to provide them.
Thank you. Dave
Instead of using an Autoexec macro, specify a startup form.