Pastebin - My Full Code
I have an issue with my program that effects my entry fields.
With my password entry it works great, the input is stored to a StringVar and can be used to test whether it has been entered correctly.
When users enter an email address or new password in the admin settings page it doesn't work, the text variable is always null.
If you could help that would be much appreciated as this is going towards an important qualification.
Problematic Areas:
Change Function
#Function that changes the system email address
def ChangeEmail(page):
global field_ChangeEmail
newEmail = field_ChangeEmail.get()
field_ChangeEmail.set('')
print(newEmail)
settingsDB = sqlite3.connect('Settings.db')
action = ("UPDATE ADMIN_SETTINGS set SYSTEM_EMAIL = '" + newEmail + "' where ID=1")
settingsDB.execute(action)
settingsDB.commit()
settingsDB.close()
Entry Field
global field_ChangeEmail
entry_ChangeEmail = tk.Entry(page, textvariable = field_ChangeEmail, justify = CENTER, fg = settings_EntryFontColour, font = settings_EntryFont)
widthRatio = settings_AS_Column03Width
heightRatio = settings_AS_RowHeight
relativeX = settings_AS_Column03RelX
relativeY = settings_AS_Row01RelY - 0.0009
entry_ChangeEmail.place(width=screenWidth*widthRatio, height=screenHeight*heightRatio, relx=relativeX, rely=relativeY, x=-((screenWidth*widthRatio)*0.5), y=-((screenHeight*heightRatio)*0.5))
There is nothing wrong with the code you posted, though your use of place and variables for sizing is very, very odd. I strongly encourage you to learn about pack or grid, it will make your GUI much, much easier to get right, and to maintain it over time. Place should never be used except when neither of the other two will work.
That being said, when I run the above code, and add a little extra to make it work, it works fine. ChangeEmail prints out the value that is in the entry widget, then clears the entry widget by setting the variable to an empty string. I assume that's what it's supposed to do.
If the text variable is getting set to null (None?), that is happening in some other part of your code.
Related
From title you can already tell what is my problem.
Somethink from my side:
I know there is for sure work around to run the macro once with creating boolean or check and hadling the error (with I still dont know how).
I want to know why the macro runs twice. My guess is that it takes mouse movement or somethink like that.
How to fix it?
Or use better alternative of capturing click on text (I want to evoid selection change/change and I am not big fan of using FollowHyperlink with linking on same cell).
Function I am using : =HYPERTEXTOVÝ.ODKAZ("#LinkClick()";"CLICK")
Eng version : =HYPERLINK("#LinkClick()";"CLICK")
Function LinkClick()
Range("A1").Value = Range("A1").Value + 1
End Function
It should be the same function. It is just different in my language :
https://support.office.com/cs-cz/article/hypertextov%C3%BD-odkaz-funkce-333c7ce6-c5ae-4164-9c47-7de9b76f577f
https://support.office.com/en-us/article/hyperlink-function-333c7ce6-c5ae-4164-9c47-7de9b76f577f?omkt=en-US&ui=en-US&rs=en-US&ad=US
PS: My first post and my english isn't best. Thanks for any answers.
You need to Set LinkClick = Selection so you return a cell with your function otherwise the link is invalid.
According to the documentation your formula =HYPERLINK("#LinkClick()";"CLICK") needs a link_location as first parameter HYPERLINK(link_location, [friendly_name]). But because you have a function call there "#LinkClick()" the function needs to return a valid link location, and that is what Set LinkClick = Selection does, it returns the actual selection as link location, so the hyperlink selects what is already selected (means it does nothing at all, but it doesn't complain about an invalid link location).
Option Explicit
Public Function LinkClick() As Range
Set LinkClick = Selection 'make sure a valid link location is returned in the function
ActiveSheet.Range("A1").Value = ActiveSheet.Range("A1").Value + 1
End Function
I have a particular FolderID and I'd like to upload files to this directory. (I have the reference to the iManage.dll and ImanEXTLib).
I'm struggling with filling out certain fields in the dialog/import window from the code level.
Ideally, I would like to skip this stage to make the upload faster. If I'm conveying all the required data then I can't see any point in the dialog besides clicking OK.
This is the code:
I'm locating the folder by using ManDMS.CreateSearchParameters
After getting results:
Dim rslts as IManFolders
Set rslts = IManSession.WorkArea.SearchFolders(<ManStrings>,<SearchParameters>)
If rslts.Empty = True Then
MsgBox "Found shit."
Elseif rslts.Empty = False Then
Dim TgtFdr as ImanFolder
Set impCmd = ImportCmd
Set context = New ContextItems
Set TgtFdr = rslts.ItemByIndex(1)
Now I'm setting the context items but I have the problem with Matter and Subclass. These are obligatory for the upload but the fields remain empty and I don't know how to address them to complete the upload:
context.Add("IManDestinationObject", TgtFdr)
context.Add("IManExt.Import.DocAuthor", UserID)
context.Add("IManExt.Import.DocDescription", file Name)
context.Add("IManExt.Import.FileName", file path)
context.Add("IManExt.Import.DocClass", "some info")
context.Add("IManExt.Import.DocSubclass", "some info")
context.Add("IManExt.Import.DocMatter", "some info")
impCmd.Initialize context
impCmd.Update
If impCmd.Status = IMANEXTLib.CommandStatus.nrActiveCommand Then
impCmd.Execute
Else
Endif
Tried different things - MatterID, MatterDesc, Custom1,2,3,. Is it possible to skip the part with this window and upload the file in a more straightforwrd way? Also, is it possible to to take out the doc number of the newly imported file at the end?
I tried:
UplDoc = (ImanDocument)context.Item("ImportedDocument")
I figured the whole thing out.
Sort of... I went into the object browser and managed to go around the problem and take advantage of the .DuplicateProfileFromDoc method. I simply mirror the profile of the uploaded doc from other already stored on worksite.
The last bit also solved.
It should be:
Set UplDoc = context.Item("ImportedDocument")
Cheers!
My Idea is not too hard. I have a button, a string called "progname", a TextBox and three Progressbars.
When I enter a number into the TextBox and press the button, the following code run's through.
Dim progname As String
progname = "Progressbar" & TextBox1.Text
Now I have a string called "progname" with relevant value.For an example "Progressbar2".
What I want to achieve is write something like:
progname.Value += 1
Which can't be done, as "Value" is not a Member of "String". How can I do this?
Overall what I want, is to be able to select one of the three progressbars by typing one of the numbers 1-3 into the TextBox and then change that ones porperties.
Yes you can.
A basic example is this, which searches your form for controls with the name matching your string. It then changes the type to a ProgressBar so you can access all the methods ..
Dim progbar As ProgressBar = CType(Me.Controls.Find(progName, False)(0), ProgressBar)
progbar.Value += 1
Q1) I have a Entry widget and I want it to be per-initilized with a value and I want the user to have the open to erase that value and type in what ever value they want.
So for example:
Year: 2016 <----- By deafult 2016 is already inputted and visible
Is there a way I can do this?
Q2) Is there a way I can set a limit to the number of a same window that can be opened? For example: If i have a drop down menu which has a "help" option. Currently the way I have it set up, if I click the help once the help window will pop up, and if I click it again (while the first window is still open) another help window will pop up. How do I set it so that only 1 help window can be opened at a time?
Any help is greatly appreciated.
1) you can use a string variable
self.example = StringVar()
self.example.set("put what you want it to say at the start here")
#note put this before you make your entry
self.example_txt = Entry(self,textvariable = self.example)
self.example_txt.place(row = 1, column = 1)
#note iv purposely missed out class declaration ectra as i am assuming you already have that)
2) there is probably a better way to do this but you could use a global variable which is set to false when the help button is clicked and set back to true when help window closed
global valid
valid = True
#not put this at start of your program
def opennewindow():
global valid
if valid == True:
valid = False
#put code for opening new window here assuming you already have that code as
#you haven't asked for code for that
def closewindow():
global valid
valid = True
self.master.destroy()
To insert something into an entry widget you can use the insert method:
e1 = tk.Entry(...)
e1.insert(0, "hello, world")
To only allow a single help window, create the help window once and hide it. Then, make your help function merely show the window rather than create it. Or, have the function check to see if the window exists; if it doesn't, create it before making it visible.
I am fairly new to Word Addin development. Fortunately I was able to do almost everything but stuck at some simple issue I belive.
I want to insert plain text controls dynamically at the selected range. For this I am using the following:
currentDocument = application.ActiveDocument;
foreach(var field in myFieldsList)
{
Microsoft.Office.Interop.Word.Range rng = currentDocument.ActiveWindow.Selection.Range;
object oRng = rng;
var contentControlPlain = application.ActiveDocument.ContentControls.Add(Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlText, ref oRng);
contentControlPlain.Tag = formField.FormFieldId.ToString();
contentControlPlain.SetPlaceholderText(null, null, " <" + formField.FormFieldName + "> ");
contentControlPlain.LockContentControl = (formField.TypeName.Trim() == "Blank");
}
Code seems to be working fine but when I try to insert the second field it complains saying:
This method or property is not available because the current selection partially covers a plain text content control.
I understand that addin is trying to insert next content control into the previously inserted plain text control. But I tried giving some other range and could not fix it.
Any help is greatly appreciated.
Thanks.
After adding every content control use
Application.Selection.Start = lastControl.Range.End+1